home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-02-28 | 143.7 KB | 5,237 lines
diff -u -r --new-file last-version/docs/DOMAIN.txt samba-1.9.16alpha1/docs/DOMAIN.txt --- last-version/docs/DOMAIN.txt Mon Jan 15 19:58:59 1996 +++ samba-1.9.16alpha1/docs/DOMAIN.txt Thu Feb 22 11:18:54 1996 @@ -6,6 +6,9 @@ administration. Support for these kind of things should be added sometime in the future. +The domain support only works for WfWg and Win95 clients. Support for +NT and OS/2 clients is still being worked on. + Using these features you can make your clients verify their logon via the Samba server and make clients run a batch file when they logon to the network. The latter is particularly useful. @@ -56,4 +59,10 @@ 6) you will probabaly find that your clients automatically mount the \\SERVER\NETLOGON share as drive z: while logging in. You can put some useful programs there to execute from the batch files. + + +NOTE: You must be using "security = user" or "security = server" for +domain logons to work correctly. Share level security won't work +correctly. + diff -u -r --new-file last-version/docs/INSTALL.txt samba-1.9.16alpha1/docs/INSTALL.txt --- last-version/docs/INSTALL.txt Mon Nov 27 10:55:51 1995 +++ samba-1.9.16alpha1/docs/INSTALL.txt Sat Feb 24 18:57:55 1996 @@ -89,6 +89,9 @@ Step 5a. Starting from inetd.conf +NOTE; The following will be different if you use NIS or NIS+ to +distributed services maps. + Look at your /etc/services. What is defined at port 139/tcp. If nothing is defined then add a line like this: diff -u -r --new-file last-version/docs/MIRRORS samba-1.9.16alpha1/docs/MIRRORS --- last-version/docs/MIRRORS Mon Nov 27 10:55:51 1995 +++ samba-1.9.16alpha1/docs/MIRRORS Tue Feb 20 20:41:42 1996 @@ -3,12 +3,15 @@ Mirror sites include: + ftp://src.doc.ic.ac.uk/packages/samba -ftp://ftp.demon.co.uk/pub/unix/samba -ftp://sunsite.unc.edu/pub/Linux/system/Network/Samba/ +ftp://ftp.warwick.ac.uk/pub/linux/sunsite.unc-mirror/system/Network/samba +ftp://sunsite.unc.edu/pub/Linux/system/Network/samba/ ftp://ftp.choc.apana.org.au/pub/samba ftp://ftp.uni-trier.de/pub/unix/network/samba/ ftp://ftp.spectrum.titan.com/pub/samba +ftp://ftp.demon.co.uk/pub/unix/unix/samba +ftp://sunsite.mff.cuni.cz/Net/Protocols/Samba There are several others. Give archie a try. diff -u -r --new-file last-version/docs/README.OS2 samba-1.9.16alpha1/docs/README.OS2 --- last-version/docs/README.OS2 Thu Jan 1 10:00:00 1970 +++ samba-1.9.16alpha1/docs/README.OS2 Tue Feb 20 11:44:07 1996 @@ -0,0 +1,81 @@ +Samba 1.9.15p8 for OS/2 : REQUIRES emx 0.9b. + + +Please read the file README, which contains general information about +the configuration and use of Samba. + + +Notes specific to OS/2 port: +============================ + +Filenames have been shortened to 8.3 in case anyone is using FAT. +Files affected are: +smb.conf -> smb.cfg smbclient -> smbclnt.exe +smbstatus -> smbstat.exe nmblookup -> nmblook.exe + +As I only use HPFS, I can't guarantee this will work on FAT systems, +although I have tried to stick to 8.3 filenames. I have noticed some +temporary files being created with long filenames by smbd when I tried +printing (which does not work yet anyway). nmbd will not be able to +create browse lists on FAT systems, as it uses temporary files with +long file names. + +smb.cfg should be in the directory smbd is started from. The path to +smb.cfg is a compile time option, so if you are compiling from source +you can set this to an absolute path to remove this restriction. + +User home directories not supported. This doesn't make much sense on +OS/2. I haven't actually disabled anything, so if you try setting +this up, behaivour is undefined. + +Password support is incomplete (I have found a crypt() routine, but +lack of passwd file support in the EMX libraries make support difficult +without major changes). + +Printing does not appear to be working. OS/2's lpq gives output in a +different format than the versions of lpq already supported by samba. +This will be easy to accomodate, but there is not much point until I can +get lpr working properly. + + + +Source is available from the Samba WWW site : + +http://lake.canberra.edu.au/pub/samba/ + +EMX 0.9b is available from hobbes.nmsu.edu, ftp.cdrom.com, ftp.leo.org and +other OS/2 FTP sites. emxrt.zip contains the required libraries. + +Bugs: +===== + +Known problems: +=============== + +Printing does not work. I have tried using REXX scripts with path info +built in, and watched the processes startup properly but nothing comes +out of the printer (remote via lpr in this case). +If you can get it going, please let me know how you did it. + +The output from OS/2's lpq.exe is not understood by smbd, so all querys +about the print queue say it is empty. Printing doesn't work anyway, +so I have not attempted to fix this yet. + +Temporary files are created with long filenames (when printing, and updating +browse list) + +Bug reports for the OS/2 port should be sent to Jason Rumney <jasonr@pec.co.nz>. + +Change log: +=========== + +Changes from release 1 to release 2. + +nmblookup (nmblook.exe) is included, and works. + +An attempt at password support was made using the gnuufc crypt routines, +but then I found that a lot of functions in the EMX libraries to do with +passwd files don't actually do anything. + +Browse lists should now work if you use HPFS and set your lock directory +to an absolute pathname. diff -u -r --new-file last-version/docs/Support.txt samba-1.9.16alpha1/docs/Support.txt --- last-version/docs/Support.txt Mon Jan 15 12:45:44 1996 +++ samba-1.9.16alpha1/docs/Support.txt Wed Feb 28 14:42:56 1996 @@ -330,3 +330,31 @@ ----------------------------------------------------------------------- +----------------------------------------------------------------------- +MELBOURNE - AUSTRALIA + +Michael Ciavarella +Cybersoruce Pty Ltd. +8/140 Queen Street +Melbourne VIC 3000 +Phone: +61-3-9642-5997 +Fax: +61-3-9642-5998 +Email: mikec@cyber.com.au +WWW: http://www.cyber.com.au + +Cybersource specialises in TCP/IP network integration and Open Systems +administration. Cybersource is an Australian-owned and operated +company, with clients including some of Australia's largest financial, +petrochemical and state government organisations. +----------------------------------------------------------------------- + +----------------------------------------------------------------------- +SOUTHERN CALIFORNIA - USA + +Michael St. Laurent +Serving Los Angeles and Orange Counties. Please contact via email. +rowl@earthlink.net +Michael St. Laurent +Hartwell Corporation +----------------------------------------------------------------------- + diff -u -r --new-file last-version/docs/nmbd.8 samba-1.9.16alpha1/docs/nmbd.8 --- last-version/docs/nmbd.8 Mon Nov 27 10:55:52 1995 +++ samba-1.9.16alpha1/docs/nmbd.8 Sun Feb 18 18:01:38 1996 @@ -28,12 +28,15 @@ ] [ .B -l .I log basename -] +] [ .B -n .I netbios name ] [ .B -p .I port number +] [ +.B -s +.I config file name ] .SH DESCRIPTION diff -u -r --new-file last-version/docs/smb.conf.5 samba-1.9.16alpha1/docs/smb.conf.5 --- last-version/docs/smb.conf.5 Mon Jan 15 20:31:25 1996 +++ samba-1.9.16alpha1/docs/smb.conf.5 Sat Feb 24 18:56:19 1996 @@ -35,7 +35,7 @@ Any line beginning with a semicolon is ignored, as are lines containing only whitespace. -Any line ending in a \ is "continued" on the next line in the +Any line ending in a \\ is "continued" on the next line in the customary unix fashion. The values following the equals sign in parameters are all either a string @@ -246,9 +246,13 @@ %u = user name of the current service, if any +%g = primary group name of %u + %U = session user name (the user name that the client wanted, not necessarily the same as the one they got) +%G = primary group name of %U + %H = the home directory of the user given by %u %v = the Samba version @@ -483,8 +487,12 @@ locking +lppause command + lpq command +lpresume command + lprm command magic output @@ -1120,6 +1128,34 @@ .SS log level (G) see "debug level" +.SS lppause command (S) +This parameter specifies the command to be executed on the server host in +order to stop printing or spooling a specific print job. + +This command should be a program or script which takes a printer name and +job number to pause the print job. Currently I don't know of any print +spooler system that can do this with a simple option, except for the PPR +system from Trinity College (ppr\-dist.trincoll.edu/pub/ppr). One way +of implementing this is by using job priorities, where jobs having a too +low priority wont be sent to the printer. See also the lppause command. + +If a %p is given then the printername is put in it's place. A %j is +replaced with the job number (an integer). +On HPUX (see printing=hpux), if the -p%p option is added to the lpq +command, the job will show up with the correct status, i.e. if the job +priority is lower than the set fence priority it will have the PAUSED +status, whereas if the priority is equal or higher it will have the +SPOOLED or PRINTING status. + +Note that it is good practice to include the absolute path in the lppause +command as the PATH may not be available to the server. + +.B Default: + Currently no default value is given to this string + +.B Example for HPUX: + lppause command = /usr/bin/lpalt %p-%j -p0 + .SS lpq cache time (G) This controls how long lpq info will be cached for to prevent the lpq @@ -1173,6 +1209,25 @@ .B Example: lpq command = /usr/bin/lpq %p +.SS lpresume command (S) +This parameter specifies the command to be executed on the server host in +order to restart or continue printing or spooling a specific print job. + +This command should be a program or script which takes a printer name and +job number to resume the print job. See also the lppause command. + +If a %p is given then the printername is put in it's place. A %j is +replaced with the job number (an integer). + +Note that it is good practice to include the absolute path in the lpresume +command as the PATH may not be available to the server. + +.B Default: + Currently no default value is given to this string + +.B Example for HPUX: + lpresume command = /usr/bin/lpalt %p-%j -p2 + .SS lprm command (S) This parameter specifies the command to be executed on the server host in order to delete a print job. @@ -1196,7 +1251,7 @@ .B Example 1: lprm command = /usr/bin/lprm -P%p %j -.B Example 1: +.B Example 2: lprm command = /usr/bin/cancel %p-%j .SS magic output (S) @@ -1324,7 +1379,7 @@ .B Example: mangling char = ^ -.SS max log file (G) +.SS max log size (G) This option (an integer in kilobytes) specifies the max size the log file should grow to. Samba periodically checks the size and if it is @@ -1485,7 +1540,7 @@ For the really adventurous, try something like this: -message command = csh -c 'csh < %s |& /usr/local/samba/smbclient \ +message command = csh -c 'csh < %s |& /usr/local/samba/smbclient \\ -M %m; rm %s' & this would execute the command as a script on the server, then give diff -u -r --new-file last-version/docs/smbclient.1 samba-1.9.16alpha1/docs/smbclient.1 --- last-version/docs/smbclient.1 Mon Nov 27 10:55:54 1995 +++ samba-1.9.16alpha1/docs/smbclient.1 Tue Feb 20 12:11:35 1996 @@ -41,6 +41,10 @@ ] [ .B -p .I port number +.B -T +.I tar options +.B -D +.I initial directory ] .SH DESCRIPTION This program is part of the Samba suite. @@ -54,14 +58,6 @@ server to the local machine, putting files from the local machine to the server, retrieving directory information from the server and so on. -NOTE: Ricky Poulten (poultenr@logica.co.uk) has written a "tar" -extension to smbclient that allows you to back up and restore your -lan-manager compatible network using smbclient. - -You can fetch the tar extension from the "contributed" section on -nimbus. ftp://nimbus.anu.edu.au/pub/tridge/samba/contributed/ - - .SH OPTIONS .B servicename .RS 3 @@ -340,6 +336,97 @@ hence the default. This parameter is not normally specified. + +.B -T +.I tar options +.RS3 + +where tar options are one or more of c,x,I,X,b,g,N or a; used as: +.LP +smbclient +.B "\\\\\\\\server\\\\share" +\-TcxIXbgNa +[ +.IR blocksize +] +[ +.IR newer-file +] +.IR tarfile +[ +.IR filenames.... +] + +.RS3 +.B c +Create a tar file on UNIX. Must be followed by the name of a tar file, +tape device or "-" for standard output. (May be useful to set debugging +low (-d0)) to avoid corrupting your tar file if using "-"). Mutually +exclusive with the x flag. + +.B x +Extract (restore) a local tar file back to a share. Unless the -D +option is given, the tar files will be restored from the top level of +the share. Must be followed by the name of the tar file, device or "-" +for standard input. Mutually exclusive with the c flag. + +.B I +Include files and directories. Is the default behaviour when +.IR filenames +are specified above. Causes tar files to be included in an extract or create +(and therefore everything else to be excluded). See example below. +Filename globbing does not work for included files for extractions (yet). + +.B X +Exclude files and directories. Causes tar files to be excluded from +an extract or create. See example below. +Filename globbing does not work for excluded files (yet). + +.B b +Blocksize. Must be followed by a valid (greater than zero) blocksize. +Causes tar file to be written out in blocksize*TBLOCK (usually 512 byte) +blocks. + +.B g +Incremental. Only back up files that have the archive bit set. Useful +only with the c flag. + +.B N +Newer than. Must be followed by the name of a file whose date is +compared against files found on the share during a create. Only files +newer than the file specified are backed up to the tar file. Useful +only with the c flag. + +.B a +Set archive bit. Causes the archive bit to be reset when a file is backed +up. Useful with the g (and c) flags. +.LP + +.B Examples + +smbclient \\\\mypc\\myshare "" -N -Tx backup.tar + +Restore from tar file backup.tar into myshare on mypc (no password on share). + +smbclient \\\\mypc\\myshare "" -N -TXx backup.tar users/docs + +Restore everything except users/docs + +smbclient \\\\mypc\\myshare "" -N -Tc backup.tar users/docs + +Create a tar file of the files beneath users/docs. + +.RE + +.B -D +.I initial directory + +.RS3 + +Change to initial directory before starting. Probably only of any use +with the tar (\-T) option. + + .RE .SH OPERATIONS @@ -894,6 +981,72 @@ .RE .RE +.B tar +.RS 3 +.B Parameters: +.RS 3 +.I <c|x>[IXbgNa] + +.RE +.B Description: +.RS 3 +Performs a tar operation - see -T command line option above. Behaviour +may be affected by the +.B tarmode +command (see below). Using the g (incremental) and N (newer) will affect +tarmode settings. Note that using the "-" option with tar x may not +work - use the command line option instead. +.RE +.RE + +.B blocksize +.RS 3 +.B Parameters +.RS 3 +.I <blocksize> + +.RE +.B Description +.RS 3 +Blocksize. Must be followed by a valid (greater than zero) blocksize. +Causes tar file to be written out in blocksize*TBLOCK (usually 512 byte) +blocks. +.RE +.RE + +.B tarmode +.RS 3 +.B Parameters +.RS 3 +.I <full|inc|reset|noreset> + +.RE +.B Description +.RS 3 +Changes tar's behaviour with regard to archive bits. In full mode, +tar will back up everything regardless of the archive bit setting (this +is the default mode). In incremental mode, tar will only back up files +with the archive bit set. In reset mode, tar will reset the archive bit +on all files it backs up (implies read/write share). +.RE +.RE + +.B setmode +.RS 3 +.B Parameters +.RS 3 +.I <filename> <perm=[+|-]rsha> + +.RE +.B Description +.RS 3 +A version of the DOS attrib command to set file permissions. For example, + +setmode myfile +r + +would make myfile read only. +.RE +.RE .SH NOTES Some servers are fussy about the case of supplied usernames, passwords, share diff -u -r --new-file last-version/docs/smbtar.1 samba-1.9.16alpha1/docs/smbtar.1 --- last-version/docs/smbtar.1 Mon Nov 27 10:55:54 1995 +++ samba-1.9.16alpha1/docs/smbtar.1 Tue Feb 20 12:11:35 1996 @@ -1,4 +1,4 @@ -.TH SMBTAR 1 6/10/1994 smbtar smbtar +.TH SMBTAR 1 18/2/96 smbtar smbtar .SH NAME smbtar \- shell script for backing up SMB shares directly to UNIX tape drive .SH SYNOPSIS @@ -11,6 +11,10 @@ .B [ \-x .I service .B ] +.B [ \-X ] +.B [ \-d +.I directory +.B ] .B [ \-u .I user .B ] @@ -20,12 +24,14 @@ .B [ \-b .I blocksize .B ] -.B [ \-n +.B [ \-N .I filename .B ] .B [ \-i ] .B [ \-r ] .B [ \-l ] +.B [ \-v ] +.I filenames... .SH DESCRIPTION This program is an extension to the Samba suite. @@ -48,6 +54,26 @@ .I backup. .RE +.B \-X +.RS 3 +Exclude mode. Exclude +.I filenames... +from tar create or restore. +.RE + +.B \-d +.I directory +.RS 3 +Change to initial +.I directory +before restoring / backing up files. +.RE + +.B \-v +.RS 3 +Verbose mode. +.RE + .B \-p .I password @@ -75,20 +101,17 @@ Blocking factor. Defaults to 20. See tar(1) for a fuller explanation. .RE -.B \-n +.B \-N .I filename .RS 3 Backup only files newer than filename. Could be used (for example) on a log -file to implement incremental backups. This flag should not be used with the -\-i flag, the results may not be sensible. +file to implement incremental backups. .RE .B \-i .RS 3 Incremental mode; tar files are only backed up if they have the archive bit set. The archive bit is reset after each file is read. -This flag should not be used with the \-n flag, the results may not be -sensible. .RE .B \-r @@ -106,9 +129,8 @@ be overidden with the -t option. .SH BUGS -The shell script has only been tested under solaris 2. It's -not very portable and should probably be customized to a particular -site's setup. +The smbtar script has different options from ordinary tar and tar +called from smbclient. .SH CAVEATS Sites that are more careful about security may not like the way @@ -116,7 +138,7 @@ should work on file lists. .SH VERSION -This man page is correct for version 1.9.02 of the Samba suite. +This man page is correct for version 1.9.15p8 of the Samba suite. .SH SEE ALSO .B smbclient @@ -134,7 +156,9 @@ of the Source for this project. Ricky Poulten (poultenr@logica.co.uk) wrote the tar extension and this -man page. +man page. The smbtar script was heavily rewritten and improved by +Martin Kraemer <Martin.Kraemer@mch.sni.de>. Many thanks to everyone +who suggested extensions, improvements, bug fixes, etc. See .B smb.conf diff -u -r --new-file last-version/examples/misc/extra_smbstatus samba-1.9.16alpha1/examples/misc/extra_smbstatus --- last-version/examples/misc/extra_smbstatus Thu Jan 1 10:00:00 1970 +++ samba-1.9.16alpha1/examples/misc/extra_smbstatus Thu Feb 22 12:05:00 1996 @@ -0,0 +1,47 @@ +Here's something that Paul Blackman sent me that may be useful: + +------------------- +I created this script to do a few things that smbstatus doesn't at the +moment. Perhaps you might want to include these. Sorry I haven't +added things at source level, script was quick&easy. + +******* +#!/bin/csh +if ($1 == "-p") then + smbstatus -p |sort -u +else if ($1 == "-c") then + echo There are `smbstatus -p |sort -u |grep -n -v z |grep -c :` unique +smbd processes running. + else if ($1 == "-l") then + echo `date '+ %d/%m/%y %H:%M:%S'` `smbstatus -p |sort -u |grep -n -v z +|grep -c :` >>$2 +else + smbstatus |sort +3 -4 -u +endif +****** + +The '-p' option was just to show unique PIDs. + +The more important ones are the '-c' and '-l' options '-c' just counts +the number of unique smbd's, While '-l' logs this count with date and +time to a log file specified on the command line. I'm using '-l' at +the moment with cron to give me an idea of usage/max connections etc. +I was also thinking of doing a log for individual/specified services. + +The default (last) option was to show unique PIDs with user names. +Unfortunately this still lists all file locks etc. This would be +better with a 'no locked files' option from smbstatus (or is there one +that I didn't see) + +Cheers, +~^ MIME OK ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ + o | Paul Blackman ictinus@lake.canberra.edu.au + o | Co-operative Research ------------------------ + o _ | Centre For Freshwater Ecology. Ph. (Aus) 06 2012518 + -- (") o | University of Canberra, Australia. Fax. " 06 2015038 + \_|_-- |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | | "Spend a little love and get high" + _/ \_ | - Lenny Kravitz +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ SAMBA Web Pages: http://samba.canberra.edu.au/pub/samba/samba.html ~~~~~ + diff -u -r --new-file last-version/examples/misc/wall.perl samba-1.9.16alpha1/examples/misc/wall.perl --- last-version/examples/misc/wall.perl Thu Jan 1 10:00:00 1970 +++ samba-1.9.16alpha1/examples/misc/wall.perl Sat Feb 24 18:54:44 1996 @@ -0,0 +1,45 @@ +#!/usr/local/bin/perl +# +#@(#) smb-wall.pl Description: +#@(#) A perl script which allows you to announce whatever you choose to +#@(#) every PC client currently connected to a Samba Server... +#@(#) ...using "smbclient -M" message to winpopup service. +#@(#) Default usage is to message every connected PC. +#@(#) Alternate usage is to message every pc on the argument list. +#@(#) Hacked up by Keith Farrar <farrar@parc.xerox.com> +# +#============================================================================= +$smbstatus = "/usr/local/bin/smbstatus"; +$smbclient = "/usr/local/bin/smbclient"; + +print STDOUT "\nEnter message for Samba clients of this host\n"; +print STDOUT "(terminated with single '.' or end of file):\n"; + +while ( <STDIN> ) { + /^\.$/ && last; + push(@message, $_); +} + +if ( $ARGV[0] ne "" ) { + $debug && print STDOUT "Was given args: \n\t @ARGV\n"; + foreach $client ( @ARGV ) { + $pcclient{$client} = $client; + } +} else { + open( PCLIST, "$smbstatus | /bin/awk '/^[a-z]/ {print $5}' | /bin/sort | /bin/uniq|"); + while ( <PCLIST> ) { + /^[a-z]+[a-z0-9A-Z-_]+.+/ || next; + ($share, $user, $group, $pid, $client, @junk) = split; + $pcclient{$client} = $client; + } + close(PCLIST); +} + +foreach $pc ( keys(%pcclient) ) { + print STDOUT "Sending message "; + $debug && print STDOUT " <@message> \n"; + print STDOUT "To <$pc>\n"; + open(SENDMSG,"|$smbclient -M $pc") || next; + print SENDMSG @message; + close(SENDMSG); +} diff -u -r --new-file last-version/source/Makefile samba-1.9.16alpha1/source/Makefile --- last-version/source/Makefile Mon Jan 15 19:02:02 1996 +++ samba-1.9.16alpha1/source/Makefile Thu Feb 29 00:12:08 1996 @@ -35,8 +35,9 @@ SHELL = /bin/sh # The following can be useful for compiling on multiple architectures -srcdir=. -VPATH=$(srcdir) +# just uncommment them putting the right directory in. +# srcdir=./ +# VPATH=$(srcdir) # set these to where to find various files # These can be overridden by command line switches (see smbd(8)) @@ -165,6 +166,16 @@ # FLAGSM = -DLINUX # LIBSM = +# Use this for Linux with shadow passwords and quota +# contributed by xeno@mix.hive.no +# Tested on the 1.3.57 kernel and ext2fs filesystem. +# Notes: +# /usr/include/sys/quota.h must be a symlink to /usr/include/linux/quota.h +# The directory quota here must be a symlink to your quota package. +# I just do 'ln -sf /usr/src/quota-1.50 quota' in this directory to get it to work. +# FLAGSM = -O3 -m486 -DLINUX -DSHADOW_PWD -DQUOTAS +# LIBSM = -lshadow + # This is for SUNOS5 (also known as Solaris 2) # contributed by Andrew.Tridgell@anu.edu.au @@ -261,6 +272,11 @@ # FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE -DDFS_AUTH -D_REENTRANT -I/usr/include/reentrant # LIBSM = -ldce -lM -lc_r +# HP-UX 10.x Trusted System +# Contributed by David-Michael Lincke (dlincke@sgcl1.unisg.ch) +# FLAGSM = +O3 -Ae -DHPUX -DHPUX_10_TRUSTED +# LIBSM = -lsec + # This is for SGI. # contributed by lpc@solomon.technet.sg (Michael Chua) @@ -358,6 +374,8 @@ # Use this for SCO OpenServer 5 with TCB passwords (default). # contributed by Scott Michel <scottm@intime.intime.com> +# you may also like to add the -dy switch (recommended by Marnus van +# Niekerk, mvn@pixie.co.za) # CC = cc -Xc # FLAGSM = -DSCO -DSecureWare -DEVEREST -DUSE_MMAP # LIBSM = -lprot -lcurses -lcrypt -lsocket -lPW -lm -lx -lc_s -lc @@ -440,6 +458,12 @@ # LIBSM = -Zexe -lsocket +# This is for LYNX 2.3.0 (gcc v2.6) +# Contributed by woelfel@hpe.fzk.de (Manfred Woelfel) +# FLAGSM = -DLYNX -DUFC_CRYPT -mposix +# LIBSM = -lbsd + + ###################################################################### # DON'T EDIT BELOW THIS LINE ###################################################################### @@ -459,7 +483,7 @@ all : CHECK $(PROGS) CHECK : - @$(SHELL) $(srcdir)/checkos.sh $(FLAGSM) + @$(SHELL) $(srcdir)checkos.sh $(FLAGSM) @echo "Using CFLAGS = $(CFLAGS)" @echo "Using LIBS = $(LIBS)" @@ -479,7 +503,7 @@ .c.o: $(INCLUDES) @echo Compiling $*.c - @$(CC) $(CFLAGS) -c $(srcdir)/$*.c + @$(CC) $(CFLAGS) -c $(srcdir)$*.c smbd: server.o $(SMBDOBJ) @echo Linking smbd @@ -497,9 +521,9 @@ @echo Linking nmbd @$(CC) $(CFLAGS) -o nmbd nameserv.o nmblib.o nmbsync.o $(PARAMOBJ) $(LIBS) -smbclient: client.o clitar.o getsmbpass.o $(UTILOBJ) +smbclient: client.o clitar.o getsmbpass.o nmblib.o $(UTILOBJ) @echo Linking smbclient - @$(CC) $(CFLAGS) -o smbclient client.o clitar.o getsmbpass.o $(UTILOBJ) $(LIBS) + @$(CC) $(CFLAGS) -o smbclient client.o clitar.o getsmbpass.o nmblib.o $(UTILOBJ) $(LIBS) smbstatus: status.o $(PARAMOBJ) @echo Linking smbstatus @@ -517,17 +541,20 @@ @echo Linking smbpasswd @$(CC) $(CFLAGS) -o smbpasswd smbpasswd.o getsmbpass.o $(PARAMOBJ) $(LIBS) -install: installbin installman +install: installbin installman installscripts installbin: all - @$(SHELL) $(srcdir)/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS) $(SCRIPTS) + @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS) + +installscripts: + @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(SCRIPTS) # revert to the previously installed version revert: - @$(SHELL) $(srcdir)/revert.sh $(BINDIR) $(PROGS) $(SCRIPTS) + @$(SHELL) $(srcdir)revert.sh $(BINDIR) $(PROGS) $(SCRIPTS) installman: - @$(SHELL) $(srcdir)/installman.sh $(MANDIR) + @$(SHELL) $(srcdir)installman.sh $(MANDIR) $(srcdir) clean: rm -f core *.o *~ $(PROGS) diff -u -r --new-file last-version/source/access.c samba-1.9.16alpha1/source/access.c --- last-version/source/access.c Sat Sep 2 15:36:15 1995 +++ samba-1.9.16alpha1/source/access.c Sat Feb 24 19:04:53 1996 @@ -317,7 +317,7 @@ if ((hp = gethostbyaddr((char *) &sockin->sin_addr, sizeof(sockin->sin_addr), AF_INET)) == 0) { - DEBUG(0,("Gethostbyaddr failed\n")); + DEBUG(1,("Gethostbyaddr failed for %s\n",addr_buf)); #ifdef ALLOW_PURE_ADDRESSES takeAddressAsHostname = True; #else diff -u -r --new-file last-version/source/change-log samba-1.9.16alpha1/source/change-log --- last-version/source/change-log Tue Jan 16 20:30:53 1996 +++ samba-1.9.16alpha1/source/change-log Thu Feb 29 00:20:21 1996 @@ -1752,14 +1752,55 @@ for SVR4 - GUEST_SESSSETUP change from David.Chappell@mail.cc.trincoll.edu - released p7 - - moved SO_REUSEADDR before bind() + - moved SO_REUSEADDR before bind() (thanks to Thomas Bellman + <tbe@ivab.se>) - added more flexible GUEST_SESSSETUP to local.h and restored pre-p7 behaviour as default - released p8 + - Makefile fix from Marty Leisner <leisner@sdsp.mc.xerox.com> + - added %g and %G substitutions + - changed IDLE_CLOSED_TIMEOUT to 60 + - fixed the "admin user" status in domain logons + - hpux 10 "trusted security" patches from David-Michael Lincke + (dlincke@sgcl1.unisg.ch) + - added nmb lookups to client from Adrian Hill <Adrian.Hill@softimage.co.uk> + - svr4 pause/resume printing patch from Brendan O'Dea (bod@tyndall.com.au) + - fixed master announcement thanks to Luke Leighton <rah14@dial.pipex.com> + - changed srcdir usage in Makefile to be friendly to more systems + - NT4 alignment patches from Jeremy Allison (jra@vantive.com) + - updated share mode code for new spec + - minor client bugfix (for smbclient '\\\') + - fix for level 260 when magling disabled. From Martin Tomes + <Martin.Tomes@ecl.etherm.co.uk> + - SMBtranss2 fix for OS/2 from Jeremy Allison + - profiles fixup from Timm Wetzel <twetzel@cage.mpibpc.gwdg.de> + - man page updates from Dirk.DeWachter@rug.ac.be + - nmbsync fix from Andy Whitcroft <andy@soi.city.ac.uk> + - Lynx patches from Manfred Woelfel <woelfel@hpesco1.fzk.de> + - new smbtar stuff from Ricky + - changed to share mode DENY_NONE for tar + - fixed -D option of smbclient when in tar mode + - added aARCH to open modes + - added code to cope with select/read errors + - fixed blank browse entries after smb.conf reread + - integrated new browse stuff from Luke into ipc.c + - added workgroup list to smbclient -L + - improved archive attribute handling in close_file() and + write_file() + - smbtar fixes from Martin.Kraemer@mch.sni.de + - Linux quota patch from xeno@mix.hsv.no + - try to work around NT passlen2 problem in session setup ========== todo: + +64 bit longs and IP addresses may give problems with unsigned longs? + +set archive bit whenever file is modified?? + +fix man page dates + reply only to own workgroup in server enum patch to compile with g++ and possibly solaris c++ @@ -1822,3 +1863,6 @@ lpd stuff: Tony Aiuto (tony@ics.com) + +make max disk size local + \ No newline at end of file diff -u -r --new-file last-version/source/client.c samba-1.9.16alpha1/source/client.c --- last-version/source/client.c Mon Jan 15 19:56:44 1996 +++ samba-1.9.16alpha1/source/client.c Thu Feb 29 00:12:08 1996 @@ -24,6 +24,7 @@ #endif #include "includes.h" +#include "nameserv.h" #ifndef REGISTER #define REGISTER 0 @@ -40,6 +41,8 @@ BOOL got_pass = False; BOOL connect_as_printer = False; BOOL connect_as_ipc = False; +extern struct in_addr bcast_ip; +static BOOL got_bcast=False; char cryptkey[8]; BOOL doencrypt=False; @@ -76,6 +79,8 @@ extern int blocksize; extern BOOL tar_inc; extern BOOL tar_reset; +extern int process_tar(); +extern int tar_parseargs(); /* clitar bits end */ @@ -123,6 +128,8 @@ extern int Client; +#define USENMB + #ifdef KANJI extern int coding_system; #define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False)) @@ -421,40 +428,47 @@ /**************************************************************************** +change directory - inner section +****************************************************************************/ +static void do_cd(char *newdir) +{ + char *p = newdir; + pstring saved_dir; + pstring dname; + + /* Save the current directory in case the + new directory is invalid */ + strcpy(saved_dir, cur_dir); + if (*p == '\\') + strcpy(cur_dir,p); + else + strcat(cur_dir,p); + if (*(cur_dir+strlen(cur_dir)-1) != '\\') { + strcat(cur_dir, "\\"); + } + dos_clean_name(cur_dir); + strcpy(dname,cur_dir); + strcat(cur_dir,"\\"); + dos_clean_name(cur_dir); + + if (!strequal(cur_dir,"\\")) + if (!chkpath(dname,True)) + strcpy(cur_dir,saved_dir); + + strcpy(cd_path,cur_dir); +} + +/**************************************************************************** change directory ****************************************************************************/ static void cmd_cd(char *inbuf,char *outbuf) { fstring buf; - char *p = buf; - pstring saved_dir; if (next_token(NULL,buf,NULL)) - { - pstring dname; - - /* Save the current directory in case the - new directory is invalid */ - strcpy(saved_dir, cur_dir); - if (*p == '\\') - strcpy(cur_dir,p); - else - strcat(cur_dir,p); - if (*(cur_dir+strlen(cur_dir)-1) != '\\') { - strcat(cur_dir, "\\"); - } - dos_clean_name(cur_dir); - strcpy(dname,cur_dir); - strcat(cur_dir,"\\"); - dos_clean_name(cur_dir); - - if (!strequal(cur_dir,"\\")) - if (!chkpath(dname,True)) - strcpy(cur_dir,saved_dir); - } + do_cd(buf); else DEBUG(0,("Current directory is %s\n",CNV_LANG(cur_dir))); - strcpy(cd_path,cur_dir); } @@ -476,6 +490,7 @@ ****************************************************************************/ void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir) { + DEBUG(5,("do_dir(%s,%x,%s)\n",Mask,attribute,BOOLSTR(recurse_dir))); if (Protocol >= PROTOCOL_LANMAN2) { if (do_long_dir(inbuf,outbuf,Mask,attribute,fn,recurse_dir) > 0) @@ -650,16 +665,13 @@ if (!fn) DEBUG(0,("\n%s\n",CNV_LANG(cur_dir))); + strcat(mask2,"*"); + if (longdir) - { - strcat(mask2,"*"); - do_long_dir(inbuf,outbuf,mask2,attribute,fn,True); - } + do_long_dir(inbuf,outbuf,mask2,attribute,fn,True); else - { - strcat(mask2,"*.*"); - do_dir(inbuf,outbuf,mask2,attribute,fn,True); - } + do_dir(inbuf,outbuf,mask2,attribute,fn,True); + strcpy(cur_dir,sav_dir); } else @@ -1076,10 +1088,7 @@ strcat(mask,p); } else { - if (Protocol < PROTOCOL_NT1) - strcat(mask,"*.*"); - else - strcat(mask,"*"); + strcat(mask,"*"); } do_dir(inbuf,outbuf,mask,attribute,NULL,recurse); @@ -1588,7 +1597,7 @@ } strcpy(mget_mask,cur_dir); - strcat(mget_mask,"*.*"); + strcat(mget_mask,"*"); do_dir((char *)inbuf,(char *)outbuf, mget_mask,aSYSTEM | aHIDDEN | aDIR,do_mget,False); @@ -1668,7 +1677,7 @@ strcpy(mget_mask,cur_dir); if(mget_mask[strlen(mget_mask)-1]!='\\') strcat(mget_mask,"\\"); - strcat(mget_mask,"*.*"); + strcat(mget_mask,"*"); do_dir((char *)inbuf,(char *)outbuf,mget_mask,attribute,do_mget,False); } } @@ -3116,7 +3125,7 @@ DEBUG(0,("Session setup failed for username=%s myname=%s destname=%s %s\n", username,myname,desthost,smb_errstr(inbuf))); - DEBUG(0,("You might find the -U or -n options useful\n")); + DEBUG(0,("You might find the -U, -W or -n options useful\n")); DEBUG(0,("Sometimes you have to use `-n USERNAME' (particularly with OS/2)\n")); DEBUG(0,("Some servers also insist on uppercase-only passwords\n")); if (was_null) @@ -3564,8 +3573,6 @@ int uLevel = 1; int count = 0; - int servertype = SV_TYPE_ALL; - /* now send a SMBtrans command with api ServerEnum? */ p = param; SSVAL(p,0,0x68); /* api number */ @@ -3582,10 +3589,10 @@ SSVAL(p,0,uLevel); SSVAL(p,2,0x2000); /* buf length */ p += 4; - SIVAL(p,0,servertype); - p += 4; - if (call_api(PTR_DIFF(p,param),0, + SIVAL(p,0,SV_TYPE_ALL); + + if (call_api(PTR_DIFF(p+4,param),0, 8,10000, &rprcnt,&rdrcnt, param,NULL, @@ -3595,29 +3602,63 @@ int converter=SVAL(rparam,2); int i; - if (res == 0) - { - count=SVAL(rparam,4); - p = rdata; + if (res == 0) { + char *p2 = rdata; + count=SVAL(rparam,4); - if (count > 0) - { + if (count > 0) { printf("\n\nThis machine has a browse list:\n"); printf("\n\tServer Comment\n"); printf("\t--------- -------\n"); } - - for (i=0;i<count;i++) - { - char *sname = p; - int comment_offset = IVAL(p,22) & 0xFFFF; + + for (i=0;i<count;i++) { + char *sname = p2; + int comment_offset = IVAL(p2,22) & 0xFFFF; printf("\t%-16.16s %s\n", sname, comment_offset?rdata+comment_offset-converter:""); - p += 26; + p2 += 26; } + } } + + if (rparam) {free(rparam); rparam = NULL;} + if (rdata) {free(rdata); rdata = NULL;} + + SIVAL(p,0,SV_TYPE_DOMAIN_ENUM); + + if (call_api(PTR_DIFF(p+4,param),0, + 8,10000, + &rprcnt,&rdrcnt, + param,NULL, + &rparam,&rdata)) + { + int res = SVAL(rparam,0); + int converter=SVAL(rparam,2); + int i; + + if (res == 0) { + char *p2 = rdata; + count=SVAL(rparam,4); + + if (count > 0) { + printf("\n\nThis machine has a workgroup list:\n"); + printf("\n\tWorkgroup Master\n"); + printf("\t--------- -------\n"); + } + + for (i=0;i<count;i++) { + char *sname = p2; + int comment_offset = IVAL(p2,22) & 0xFFFF; + printf("\t%-16.16s %s\n", + sname, + comment_offset?rdata+comment_offset-converter:""); + + p2 += 26; + } + } } if (rparam) free(rparam); @@ -3671,10 +3712,10 @@ {"exit",send_logout,"logoff the server"}, {"newer",cmd_newer,"<file> only mget files newer than the specified local file"}, {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit"}, - {"tar",cmd_tar,"tar current directory to <file name>" }, + {"tar",cmd_tar,"tar <c|x>[IXbgNa] current directory to/from <file name>" }, {"blocksize",cmd_block,"blocksize <number> (default 20)" }, {"tarmode",cmd_tarmode, - "<mode=full|inc|reset|noreset> tar's behaviour towards archive bits" }, + "<full|inc|reset|noreset> tar's behaviour towards archive bits" }, {"setmode",cmd_setmode,"filename <setmode string> change modes of file"}, {"help",cmd_help,"[command] give help on a command"}, {"?",cmd_help,"[command] give help on a command"}, @@ -3690,7 +3731,7 @@ static int process_tok(fstring tok) { int i = 0, matches = 0; - int cmd; + int cmd=0; int tok_len = strlen(tok); while (commands[i].fn != NULL) @@ -3750,6 +3791,9 @@ char *host; pstring service2; extern int Client; +#ifdef USENMB + BOOL failed = True; +#endif if (port == 0) port=last_port; last_port=port; @@ -3764,6 +3808,10 @@ { strcpy(service2,service); host = strtok(service2,"\\/"); + if (!host) { + DEBUG(0,("Badly formed host name\n")); + return(False); + } strcpy(desthost,host); } @@ -3779,13 +3827,34 @@ { struct hostent *hp; - if ((hp = Get_Hostbyname(host)) == 0) - { + if ((hp = Get_Hostbyname(host))) { + putip((char *)&dest_ip,(char *)hp->h_addr); + failed = False; + } else { +#ifdef USENMB + /* Try and resolve the name with the netbios server */ + int bcast; + pstring hs; + struct in_addr ip1, ip2; + + if ((bcast = open_socket_in(SOCK_DGRAM, 0, 3)) != -1) { + set_socket_options (bcast, "SO_BROADCAST"); + + if (!got_bcast && get_myname(hs, &ip1)) { + get_broadcast(&ip1, &bcast_ip, &ip2); + } + + if (name_query(bcast, host, 0x20, True, True, bcast_ip, &dest_ip,0)){ + failed = False; + } + close (bcast); + } +#endif + if (failed) { DEBUG(0,("Get_Hostbyname: Unknown host %s.\n",host)); return False; } - - putip((char *)&dest_ip,(char *)hp->h_addr); + } } Client = open_socket_out(SOCK_STREAM, &dest_ip, port); @@ -3793,9 +3862,9 @@ return False; DEBUG(3,("Connected\n")); - + set_socket_options(Client,user_socket_options); - + return True; } @@ -3906,7 +3975,7 @@ /**************************************************************************** process commands from the client ****************************************************************************/ -BOOL process(void ) +BOOL process(char *base_directory) { extern FILE *dbf; pstring line; @@ -3922,6 +3991,8 @@ if (!send_login(InBuffer,OutBuffer,True,True)) return(False); + if (*base_directory) do_cd(base_directory); + while (!feof(stdin)) { fstring tok; @@ -4008,6 +4079,8 @@ #ifdef KANJI DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n")); #endif /* KANJI */ + DEBUG(0,("\t-T<c|x>IXgbNa command line tar\n")); + DEBUG(0,("\t-D directory start from directory\n")); DEBUG(0,("\n")); } @@ -4018,15 +4091,19 @@ ****************************************************************************/ int main(int argc,char *argv[]) { + fstring base_directory; char *pname = argv[0]; int port = 139; int opt; extern FILE *dbf; extern char *optarg; + extern int optind; pstring query_host; BOOL message = False; + extern char tar_type; *query_host = 0; + *base_directory = 0; DEBUGLEVEL = 2; @@ -4095,9 +4172,9 @@ #ifdef KANJI setup_term_code (KANJI); - while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:")) != EOF) + while ((opt = getopt (argc, argv, "B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:")) != EOF) #else - while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:W:")) != EOF) + while ((opt = getopt (argc, argv, "B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:W:T:D:")) != EOF) #endif /* KANJI */ switch (opt) { @@ -4113,6 +4190,19 @@ strupper(desthost); message = True; break; + case 'B': + bcast_ip = *interpret_addr2(optarg); + got_bcast = True; + break; + case 'D': + strcpy(base_directory,optarg); + break; + case 'T': + if (!tar_parseargs(argc, argv, optarg, optind)) { + usage(pname); + exit(1); + } + break; case 'i': strcpy(scope,optarg); break; @@ -4186,7 +4276,7 @@ exit(1); } - if (!*query_host && !*service && !message) + if (!tar_type && !*query_host && !*service && !message) { usage(pname); exit(1); @@ -4197,6 +4287,32 @@ get_myname(*myname?NULL:myname,&myip); strupper(myname); + + if (tar_type) { + recurse=True; + + if (open_sockets(port)) { + char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + char *OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + int ret; + + if ((InBuffer == NULL) || (OutBuffer == NULL)) + return(1); + + bzero(OutBuffer,smb_size); + if (!send_login(InBuffer,OutBuffer,True,True)) + return(False); + + if (*base_directory) do_cd(base_directory); + + ret=process_tar(InBuffer, OutBuffer); + + send_logout(); + close_sockets(); + return(ret); + } else + return(1); + } if (*query_host) { @@ -4249,7 +4365,7 @@ if (open_sockets(port)) { - if (!process()) + if (!process(base_directory)) { close_sockets(); return(1); @@ -4301,6 +4417,7 @@ {"ERRpipeclosing",232,"Pipe close in progress."}, {"ERRnotconnected",233,"No process on other end of pipe."}, {"ERRmoredata",234,"There is more data to be returned."}, + {"ERRinvgroup",2455,"Invalid workgroup (try the -W option)"}, {NULL,-1,NULL}}; /* Server Error Messages */ diff -u -r --new-file last-version/source/clitar.c samba-1.9.16alpha1/source/clitar.c --- last-version/source/clitar.c Mon Jan 15 18:37:04 1996 +++ samba-1.9.16alpha1/source/clitar.c Sat Feb 24 19:04:53 1996 @@ -27,6 +27,8 @@ extern BOOL reopen_connection(char *inbuf,char *outbuf); extern void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir); +int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind); + extern BOOL recurse; #define SEPARATORS " \t\n\r" @@ -38,14 +40,23 @@ #define ATTRSET 1 #define ATTRRESET 0 +static int attribute = aDIR | aSYSTEM | aHIDDEN; + #ifndef CLIENT_TIMEOUT #define CLIENT_TIMEOUT (30*1000) #endif static char *tarbuf; static int tp, ntarf, tbufsiz; +/* Incremental mode */ BOOL tar_inc=False; +/* Reset archive bit */ BOOL tar_reset=False; +/* Include / exclude mode (true=include, false=exclude) */ +BOOL tar_excl=True; +char tar_type='\0'; +static char **cliplist=NULL; +static int clipn=0; extern file_info def_finfo; extern BOOL lowercase; @@ -62,8 +73,7 @@ static void writetarheader(); static void do_atar(); -void do_tar(); -void cmd_tar(); +static void do_tar(); static void oct_it(); static void fixtarname(); static int dotarbuf(); @@ -71,18 +81,23 @@ static void dotareof(); static void initarbuf(); static int do_setrattr(); - -/* begin smbrestore functions */ +void cmd_tar(); +int process_tar(); +char **toktocliplist(); +int clipfind(); +/* restore functions */ static long readtarheader(); static long unoct(); static void do_tarput(); static void unfixtarname(); -/* end smbrestore functions */ /* - * utitlity procedures to implement tar specification including buffering + * tar specific utitlities */ +/**************************************************************************** +Write a tar header to buffer +****************************************************************************/ static void writetarheader(int f, char *aname, int size, time_t mtime, char *amode) { @@ -124,11 +139,90 @@ (void) dotarbuf(f, hb.dummy, sizeof(hb.dummy)); } +/**************************************************************************** +Read a tar header into a hblock structure, and validate +***************************************************************************/ +static long readtarheader(union hblock *hb, file_info *finfo, char *prefix) +{ + long chk, fchk; + int i; + char *jp; + + /* + * read in a "standard" tar format header - we're not that interested + * in that many fields, though + */ + + /* check the checksum */ + for (chk=0, i=sizeof(hb->dummy), jp=hb->dummy; --i>=0;) chk+=(0xFF & *jp++); + + if (chk == 0) + return chk; + + /* compensate for blanks in chksum header */ + for (i=sizeof(hb->dbuf.chksum), jp=hb->dbuf.chksum; --i>=0;) + chk-=(0xFF & *jp++); + + chk += ' ' * sizeof(hb->dbuf.chksum); + + fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum)); + + DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n", + chk, fchk, hb->dbuf.chksum)); + + if (fchk != chk) + { + DEBUG(0, ("checksums don't match %d %d\n", fchk, chk)); + return -1; + } + + strcpy(finfo->name, prefix); + + /* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */ + unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name, + strlen(hb->dbuf.name) + 1); + +/* can't handle links at present */ + if (hb->dbuf.linkflag != '0') { + if (hb->dbuf.linkflag == 0) { + DEBUG(6, ("Warning: NULL link flag (gnu tar archive ?) %s\n", + finfo->name)); + } else { + DEBUG(0, ("this tar file appears to contain some kind of link - ignoring\n")); + return -2; + } + } + + if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR) + || (*(finfo->name+strlen(finfo->name)-1) == '\\')) + { + finfo->mode=aDIR; + } + else + finfo->mode=0; /* we don't care about mode at the moment, we'll + * just make it a regular file */ + /* + * Bug fix by richard@sj.co.uk + * + * REC: restore times correctly (as does tar) + * We only get the modification time of the file; set the creation time + * from the mod. time, and the access time to current time + */ + finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8); + finfo->atime = time(NULL); + finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size)); + + return True; +} +/**************************************************************************** +Write out the tar buffer to tape or wherever +****************************************************************************/ static int dotarbuf(int f, char *b, int n) { int fail=1, writ=n; + /* This routine and the next one should be the only ones that do write()s */ if (tp + n >= tbufsiz) { int diff; @@ -155,6 +249,9 @@ return(fail ? writ : 0); } +/**************************************************************************** +Write a zeros to buffer / tape +****************************************************************************/ static void dozerobuf(int f, int n) { /* short routine just to write out n zeros to buffer - @@ -174,6 +271,9 @@ } } +/**************************************************************************** +Malloc tape buffer +****************************************************************************/ static void initarbuf() { /* initialize tar buffer */ @@ -184,11 +284,13 @@ tp=0; ntarf=0; } +/**************************************************************************** +Write two zero blocks at end of file +****************************************************************************/ static void dotareof(int f) { struct stat stbuf; - /* Two zero blocks at end of file, write out full buffer - * no matter what; well that's what the manual says */ + /* Two zero blocks at end of file, write out full buffer */ (void) dozerobuf(f, TBLOCK); (void) dozerobuf(f, TBLOCK); @@ -199,9 +301,14 @@ return; } + /* Could be a pipe, in which case S_ISREG should fail, + * and we should write out at full size */ if (tp > 0) write(f, tarbuf, S_ISREG(stbuf.st_mode) ? tp : tbufsiz); } +/**************************************************************************** +(Un)mangle DOS pathname, make nonabsolute +****************************************************************************/ static void fixtarname(char *tptr, char *fp, int l) { /* add a '.' to start of file name, convert from ugly dos \'s in path @@ -231,6 +338,9 @@ #endif } +/**************************************************************************** +Convert from decimal to octal string +****************************************************************************/ static void oct_it (register long value, register int ndgs, register char *p) { /* Converts long to octal string, pads with leading zeros */ @@ -251,10 +361,47 @@ p[--ndgs] = '0'; } +/**************************************************************************** +Convert from octal string to long +***************************************************************************/ +static long unoct(char *p, int ndgs) +{ + long value=0; + /* Converts octal string to long, ignoring any non-digit */ + + while (--ndgs) + { + if (isdigit(*p)) + value = (value << 3) | (long) (*p - '0'); + + p++; + } + + return value; +} + +/**************************************************************************** +Compare two strings in a slash insensitive way +***************************************************************************/ +int strslashcmp(const char *s1, const char *s2) +{ + while(*s1 && *s2 && + (*s1 == *s2 + || tolower(*s1) == tolower(*s2) + || (*s1 == '\\' && *s2=='/') + || (*s1 == '/' && *s2=='\\'))) { + s1++; s2++; + } + + return *s1-*s2; +} + /* * general smb utility functions */ - +/**************************************************************************** +Set DOS file attributes +***************************************************************************/ static int do_setrattr(char *fname, int attr, int setit) { /* @@ -347,122 +494,338 @@ return(True); } -/* - * smbclient support procedures - */ - /**************************************************************************** - do a tar operation on one file +Create a file on a share ***************************************************************************/ - -static void do_atar(char *rname,char *lname,file_info *finfo1) +static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf) { - int fnum; - uint32 nread=0; char *p; - char *inbuf,*outbuf; - file_info finfo; - BOOL close_done = False; - BOOL shallitime=True; - BOOL ignore_close_error = False; - char *dataptr=NULL; - int datalen=0; - - struct timeval tp_start; - GetTimeOfDay(&tp_start); - - if (finfo1) - finfo = *finfo1; - else - finfo = def_finfo; - - inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - - if (!inbuf || !outbuf) - { - DEBUG(0,("out of memory\n")); - return; - } - + /* *must* be called with buffer ready malloc'ed */ + /* open remote file */ + memset(outbuf,0,smb_size); - set_message(outbuf,15,1 + strlen(rname),True); - - CVAL(outbuf,smb_com) = SMBopenX; + set_message(outbuf,3,2 + strlen(finfo.name),True); + CVAL(outbuf,smb_com) = SMBcreate; SSVAL(outbuf,smb_tid,cnum); setup_pkt(outbuf); - - SSVAL(outbuf,smb_vwv0,0xFF); - SSVAL(outbuf,smb_vwv2,1); - SSVAL(outbuf,smb_vwv4,aSYSTEM | aHIDDEN); - SSVAL(outbuf,smb_vwv5,aSYSTEM | aHIDDEN); - SSVAL(outbuf,smb_vwv8,1); - + + SSVAL(outbuf,smb_vwv0,finfo.mode); + put_dos_date3(outbuf,smb_vwv1,finfo.mtime); + p = smb_buf(outbuf); - strcpy(p,rname); - p = skip_string(p,1); - - dos_clean_name(rname); - - /* do a chained openX with a readX? */ - if (finfo.size > 0) - { - SSVAL(outbuf,smb_vwv0,SMBreadX); - SSVAL(outbuf,smb_vwv1,PTR_DIFF(p,outbuf) - 4); - memset(p,0,200); - p -= smb_wct; - SSVAL(p,smb_wct,10); - SSVAL(p,smb_vwv0,0xFF); - SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size)); - SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size)); - smb_setlen(outbuf,smb_len(outbuf)+11*2+1); - } + *p++ = 4; + strcpy(p,finfo.name); send_smb(Client,outbuf); receive_smb(Client,inbuf,CLIENT_TIMEOUT); - + if (CVAL(inbuf,smb_rcls) != 0) { - if (CVAL(inbuf,smb_rcls) == ERRSRV && - SVAL(inbuf,smb_err) == ERRnoresource && - reopen_connection(inbuf,outbuf)) - { - do_atar(rname,lname,finfo1); - free(inbuf);free(outbuf); - return; - } - - DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),rname)); - free(inbuf);free(outbuf); - return; - } - - strcpy(finfo.name,rname); - if (!finfo1) - { - finfo.mode = SVAL(inbuf,smb_vwv3); - finfo.size = IVAL(inbuf,smb_vwv4); - finfo.mtime = make_unix_date3(inbuf+smb_vwv6); - finfo.atime = finfo.ctime = finfo.mtime; + DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf), + finfo.name)); + return 0; } + + *fnum = SVAL(inbuf,smb_vwv0); + return True; +} - DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode)); +/**************************************************************************** +Write a file to a share +***************************************************************************/ +static BOOL smbwrite(int fnum, int n, int low, int high, int left, + char *bufferp, char *inbuf, char *outbuf) +{ + /* *must* be called with buffer ready malloc'ed */ - fnum = SVAL(inbuf,smb_vwv2); + memset(outbuf,0,smb_size); + set_message(outbuf,5,n + 3,True); + + memcpy(smb_buf(outbuf)+3, bufferp, n); + + set_message(outbuf,5,n + 3, False); + CVAL(outbuf,smb_com) = SMBwrite; + SSVAL(outbuf,smb_tid,cnum); + setup_pkt(outbuf); + + SSVAL(outbuf,smb_vwv0,fnum); + SSVAL(outbuf,smb_vwv1,n); + SIVAL(outbuf,smb_vwv2,low); + SSVAL(outbuf,smb_vwv4,left); + CVAL(smb_buf(outbuf),0) = 1; + SSVAL(smb_buf(outbuf),1,n); - if (tar_inc && !(finfo.mode & aARCH)) + send_smb(Client,outbuf); + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + if (CVAL(inbuf,smb_rcls) != 0) { - DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name)); - shallitime=0; + DEBUG(0,("%s writing remote file\n",smb_errstr(inbuf))); + return False; } - else + + if (n != SVAL(inbuf,smb_vwv0)) { - if (SVAL(inbuf,smb_vwv0) == SMBreadX) - { - p = (inbuf+4+SVAL(inbuf,smb_vwv1)) - smb_wct; - datalen = SVAL(p,smb_vwv5); - dataptr = inbuf + 4 + SVAL(p,smb_vwv6); - } + DEBUG(0,("Error: only wrote %d bytes out of %d\n", + SVAL(inbuf,smb_vwv0), n)); + return False; + } + + return True; +} + +/**************************************************************************** +Close a file on a share +***************************************************************************/ +static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf) +{ + /* *must* be called with buffer ready malloc'ed */ + + memset(outbuf,0,smb_size); + set_message(outbuf,3,0,True); + CVAL(outbuf,smb_com) = SMBclose; + SSVAL(outbuf,smb_tid,cnum); + setup_pkt(outbuf); + + SSVAL(outbuf,smb_vwv0,fnum); + put_dos_date3(outbuf,smb_vwv1,finfo.mtime); + + DEBUG(3,("Setting date to %s (0x%X)", + asctime(LocalTime(&finfo.mtime,GMT_TO_LOCAL)), + finfo.mtime)); + + send_smb(Client,outbuf); + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + if (CVAL(inbuf,smb_rcls) != 0) + { + DEBUG(0,("%s closing remote file %s\n",smb_errstr(inbuf), + finfo.name)); + return False; + } + + return True; +} + +/**************************************************************************** +Verify existence of path on share +***************************************************************************/ +static BOOL smbchkpath(char *fname, char *inbuf, char *outbuf) +{ + char *p; + + memset(outbuf,0,smb_size); + set_message(outbuf,0,4 + strlen(fname),True); + CVAL(outbuf,smb_com) = SMBchkpth; + SSVAL(outbuf,smb_tid,cnum); + setup_pkt(outbuf); + + p = smb_buf(outbuf); + *p++ = 4; + strcpy(p,fname); + + send_smb(Client,outbuf); + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + DEBUG(5,("smbchkpath: %s\n",smb_errstr(inbuf))); + + return(CVAL(inbuf,smb_rcls) == 0); +} + +/**************************************************************************** +Make a directory on share +***************************************************************************/ +static BOOL smbmkdir(char *fname, char *inbuf, char *outbuf) +{ + /* *must* be called with buffer ready malloc'ed */ + char *p; + + memset(outbuf,0,smb_size); + set_message(outbuf,0,2 + strlen(fname),True); + + CVAL(outbuf,smb_com) = SMBmkdir; + SSVAL(outbuf,smb_tid,cnum); + setup_pkt(outbuf); + + p = smb_buf(outbuf); + *p++ = 4; + strcpy(p,fname); + + send_smb(Client,outbuf); + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + if (CVAL(inbuf,smb_rcls) != 0) + { + DEBUG(0,("%s making remote directory %s\n", + smb_errstr(inbuf),fname)); + return(False); + } + + return(True); +} + +/**************************************************************************** +Ensure a remote path exists (make if necessary) +***************************************************************************/ +static BOOL ensurepath(char *fname, char *inbuf, char *outbuf) +{ + /* *must* be called with buffer ready malloc'ed */ + /* ensures path exists */ + + pstring partpath, ffname; + char *p=fname, *basehack; + + *partpath = 0; + + /* fname copied to ffname so can strtok */ + + strcpy(ffname, fname); + + /* do a `basename' on ffname, so don't try and make file name directory */ + if ((basehack=strrchr(ffname, '\\')) == NULL) + return True; + else + *basehack='\0'; + + p=strtok(ffname, "\\"); + + while (p) + { + strcat(partpath, p); + + if (!smbchkpath(partpath, inbuf, outbuf)) { + if (!smbmkdir(partpath, inbuf, outbuf)) + { + DEBUG(0, ("Error mkdirhiering\n")); + return False; + } + else + DEBUG(3, ("mkdirhiering %s\n", partpath)); + + } + + strcat(partpath, "\\"); + p = strtok(NULL,"/\\"); + } + + return True; +} + +/* + * smbclient functions + */ +/**************************************************************************** +append one remote file to the tar file +***************************************************************************/ +static void do_atar(char *rname,char *lname,file_info *finfo1) +{ + int fnum; + uint32 nread=0; + char *p; + char *inbuf,*outbuf; + file_info finfo; + BOOL close_done = False; + BOOL shallitime=True; + BOOL ignore_close_error = False; + char *dataptr=NULL; + int datalen=0; + + struct timeval tp_start; + GetTimeOfDay(&tp_start); + + if (finfo1) + finfo = *finfo1; + else + finfo = def_finfo; + + inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + + if (!inbuf || !outbuf) + { + DEBUG(0,("out of memory\n")); + return; + } + + memset(outbuf,0,smb_size); + set_message(outbuf,15,1 + strlen(rname),True); + + CVAL(outbuf,smb_com) = SMBopenX; + SSVAL(outbuf,smb_tid,cnum); + setup_pkt(outbuf); + + SSVAL(outbuf,smb_vwv0,0xFF); + SSVAL(outbuf,smb_vwv2,1); + SSVAL(outbuf,smb_vwv3,(DENY_NONE<<4)); + SSVAL(outbuf,smb_vwv4,aSYSTEM | aHIDDEN); + SSVAL(outbuf,smb_vwv5,aSYSTEM | aHIDDEN); + SSVAL(outbuf,smb_vwv8,1); + + p = smb_buf(outbuf); + strcpy(p,rname); + p = skip_string(p,1); + + dos_clean_name(rname); + + /* do a chained openX with a readX? */ + if (finfo.size > 0) + { + SSVAL(outbuf,smb_vwv0,SMBreadX); + SSVAL(outbuf,smb_vwv1,PTR_DIFF(p,outbuf) - 4); + memset(p,0,200); + p -= smb_wct; + SSVAL(p,smb_wct,10); + SSVAL(p,smb_vwv0,0xFF); + SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size)); + SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size)); + smb_setlen(outbuf,smb_len(outbuf)+11*2+1); + } + + send_smb(Client,outbuf); + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + if (CVAL(inbuf,smb_rcls) != 0) + { + if (CVAL(inbuf,smb_rcls) == ERRSRV && + SVAL(inbuf,smb_err) == ERRnoresource && + reopen_connection(inbuf,outbuf)) + { + do_atar(rname,lname,finfo1); + free(inbuf);free(outbuf); + return; + } + + DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),rname)); + free(inbuf);free(outbuf); + return; + } + + strcpy(finfo.name,rname); + if (!finfo1) + { + finfo.mode = SVAL(inbuf,smb_vwv3); + finfo.size = IVAL(inbuf,smb_vwv4); + finfo.mtime = make_unix_date3(inbuf+smb_vwv6); + finfo.atime = finfo.ctime = finfo.mtime; + } + + DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode)); + + fnum = SVAL(inbuf,smb_vwv2); + + if (tar_inc && !(finfo.mode & aARCH)) + { + DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name)); + shallitime=0; + } + else + { + if (SVAL(inbuf,smb_vwv0) == SMBreadX) + { + p = (inbuf+4+SVAL(inbuf,smb_vwv1)) - smb_wct; + datalen = SVAL(p,smb_vwv5); + dataptr = inbuf + 4 + SVAL(p,smb_vwv6); + } else { dataptr = NULL; @@ -722,390 +1085,119 @@ (tp_end.tv_sec - tp_start.tv_sec)*1000 + (tp_end.tv_usec - tp_start.tv_usec)/1000; get_total_time_ms += this_time; - get_total_size += finfo.size; - - DEBUG(2,("(%g kb/s) (average %g kb/s)\n", - finfo.size / (1.024*this_time + 1.0e-4), - get_total_size / (1.024*get_total_time_ms))); - } - - free(inbuf);free(outbuf); -} - - - -void do_tar(file_info *finfo) -{ - pstring rname; - - if (strequal(finfo->name,".") || strequal(finfo->name,"..")) - return; - - if (finfo->mode & aDIR) - { - pstring saved_curdir; - pstring mtar_mask; - char *inbuf,*outbuf; - - inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - - if (!inbuf || !outbuf) - { - DEBUG(0,("out of memory\n")); - return; - } - - strcpy(saved_curdir,cur_dir); - - strcat(cur_dir,finfo->name); - strcat(cur_dir,"\\"); - - /* write a tar directory, don't bother with mode - just set it to - * 40755 */ - writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0"); - strcpy(mtar_mask,cur_dir); - strcat(mtar_mask,"*.*"); - - do_dir((char *)inbuf,(char *)outbuf, - mtar_mask,aSYSTEM | aHIDDEN | aDIR,do_tar,recurse); - strcpy(cur_dir,saved_curdir); - free(inbuf);free(outbuf); - } - else - { - strcpy(rname,cur_dir); - strcat(rname,finfo->name); - do_atar(rname,finfo->name,finfo); - } -} - -/* - * - * restore specific functions - * - */ - -static long readtarheader(union hblock *hb, file_info *finfo, char *prefix) -{ - long chk, fchk; - int i; - char *jp; - - /* - * read in a "standard" tar format header - we're not that interested - * in that many fields, though - */ - - /* check the checksum */ - for (chk=0, i=sizeof(hb->dummy), jp=hb->dummy; --i>=0;) chk+=(0xFF & *jp++); - - if (chk == 0) - return chk; - - /* compensate for blanks in chksum header */ - for (i=sizeof(hb->dbuf.chksum), jp=hb->dbuf.chksum; --i>=0;) - chk-=(0xFF & *jp++); - - chk += ' ' * sizeof(hb->dbuf.chksum); - - fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum)); - - DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n", - chk, fchk, hb->dbuf.chksum)); - - if (fchk != chk) - { - DEBUG(0, ("checksums don't match %d %d\n", fchk, chk)); - return -1; - } - - strcpy(finfo->name, prefix); - - /* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */ - unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name, - strlen(hb->dbuf.name) + 1); - -/* can't handle links at present */ - if (hb->dbuf.linkflag != '0') { - if (hb->dbuf.linkflag == 0) { - DEBUG(4, ("Warning: NULL link detected %s\n", finfo->name)); - } else { - DEBUG(0, ("this tar file appears to contain some kind of link - ignoring\n")); - return -2; - } - } - - if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR) - || (*(finfo->name+strlen(finfo->name)-1) == '\\')) - { - finfo->mode=aDIR; - } - else - finfo->mode=0; /* we don't care about mode at the moment, we'll - * just make it a regular file */ - /* - * Bug fix by richard@sj.co.uk - * - * REC: restore times correctly (as does tar) - * We only get the modification time of the file; set the creation time - * from the mod. time, and the access time to current time - */ - finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8); - finfo->atime = time(NULL); - finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size)); - - return True; -} - -static void unfixtarname(char *tptr, char *fp, int l) -{ - /* remove '.' from start of file name, convert from unix /'s to - * dos \'s in path. Kill any absolute path names. - */ - - if (*fp == '.') fp++; - if (*fp == '\\' || *fp == '/') fp++; - -#ifdef KANJI - while (l > 0) { - if (is_shift_jis (*fp)) { - *tptr++ = *fp++; - *tptr++ = *fp++; - l -= 2; - } else if (is_kana (*fp)) { - *tptr++ = *fp++; - l--; - } else if (*fp == '/') { - *tptr++ = '\\'; - fp++; - l--; - } else { - *tptr++ = *fp++; - l--; - } - } -#else - while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; } -#endif -} - -static long unoct(char *p, int ndgs) -{ - long value=0; - /* Converts octal string to long, ignoring any non-digit */ - - while (--ndgs) - { - if (isdigit(*p)) - value = (value << 3) | (long) (*p - '0'); - - p++; - } - - return value; -} - -static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf) -{ - char *p; - /* *must* be called with buffer ready malloc'ed */ - /* open remote file */ - - memset(outbuf,0,smb_size); - set_message(outbuf,3,2 + strlen(finfo.name),True); - CVAL(outbuf,smb_com) = SMBcreate; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - SSVAL(outbuf,smb_vwv0,finfo.mode); - put_dos_date3(outbuf,smb_vwv1,finfo.mtime); - - p = smb_buf(outbuf); - *p++ = 4; - strcpy(p,finfo.name); - - send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); - - if (CVAL(inbuf,smb_rcls) != 0) - { - DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf), - finfo.name)); - return 0; - } - - *fnum = SVAL(inbuf,smb_vwv0); - return True; -} - - -static BOOL smbwrite(int fnum, int n, int low, int high, int left, - char *bufferp, char *inbuf, char *outbuf) -{ - /* *must* be called with buffer ready malloc'ed */ - - memset(outbuf,0,smb_size); - set_message(outbuf,5,n + 3,True); - - memcpy(smb_buf(outbuf)+3, bufferp, n); - - set_message(outbuf,5,n + 3, False); - CVAL(outbuf,smb_com) = SMBwrite; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - SSVAL(outbuf,smb_vwv0,fnum); - SSVAL(outbuf,smb_vwv1,n); - SIVAL(outbuf,smb_vwv2,low); - SSVAL(outbuf,smb_vwv4,left); - CVAL(smb_buf(outbuf),0) = 1; - SSVAL(smb_buf(outbuf),1,n); - - send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); - - if (CVAL(inbuf,smb_rcls) != 0) - { - DEBUG(0,("%s writing remote file\n",smb_errstr(inbuf))); - return False; - } - - if (n != SVAL(inbuf,smb_vwv0)) - { - DEBUG(0,("Error: only wrote %d bytes out of %d\n", - SVAL(inbuf,smb_vwv0), n)); - return False; - } - - return True; -} - -static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf) -{ - /* *must* be called with buffer ready malloc'ed */ - - memset(outbuf,0,smb_size); - set_message(outbuf,3,0,True); - CVAL(outbuf,smb_com) = SMBclose; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - SSVAL(outbuf,smb_vwv0,fnum); - put_dos_date3(outbuf,smb_vwv1,finfo.mtime); - - DEBUG(3,("Setting date to %s (0x%X)", - asctime(LocalTime(&finfo.mtime,GMT_TO_LOCAL)), - finfo.mtime)); - - send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); - - if (CVAL(inbuf,smb_rcls) != 0) - { - DEBUG(0,("%s closing remote file %s\n",smb_errstr(inbuf), - finfo.name)); - return False; - } - - return True; -} - - -static BOOL smbchkpath(char *fname, char *inbuf, char *outbuf) -{ - char *p; - - memset(outbuf,0,smb_size); - set_message(outbuf,0,4 + strlen(fname),True); - CVAL(outbuf,smb_com) = SMBchkpth; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - p = smb_buf(outbuf); - *p++ = 4; - strcpy(p,fname); + get_total_size += finfo.size; - send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); + /* Thanks to Carel-Jan Engel (ease@mail.wirehub.nl) for this one */ + DEBUG(2,("(%g kb/s) (average %g kb/s)\n", + finfo.size / MAX(0.001, (1.024*this_time)), + get_total_size / MAX(0.001, (1.024*get_total_time_ms)))); + } + + free(inbuf);free(outbuf); +} - DEBUG(5,("smbchkpath: %s\n",smb_errstr(inbuf))); +/**************************************************************************** +Append single file to tar file (or not) +***************************************************************************/ +static void do_tar(file_info *finfo) +{ + pstring rname; - return(CVAL(inbuf,smb_rcls) == 0); -} + if (strequal(finfo->name,".") || strequal(finfo->name,"..")) + return; + /* Is it on the exclude list ? */ + if (!tar_excl && clipn) { + pstring exclaim; -static BOOL smbmkdir(char *fname, char *inbuf, char *outbuf) -{ - /* *must* be called with buffer ready malloc'ed */ - char *p; + strcpy(exclaim, cur_dir); + *(exclaim+strlen(exclaim)-1)='\0'; - memset(outbuf,0,smb_size); - set_message(outbuf,0,2 + strlen(fname),True); - - CVAL(outbuf,smb_com) = SMBmkdir; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - p = smb_buf(outbuf); - *p++ = 4; - strcpy(p,fname); - - send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); - - if (CVAL(inbuf,smb_rcls) != 0) - { - DEBUG(0,("%s making remote directory %s\n", - smb_errstr(inbuf),fname)); - return(False); + if (clipfind(cliplist, clipn, exclaim)) { + DEBUG(3,("Skipping directory %s\n", exclaim)); + return; } - return(True); -} - -static BOOL ensurepath(char *fname, char *inbuf, char *outbuf) -{ - /* *must* be called with buffer ready malloc'ed */ - /* ensures path exists */ + strcat(exclaim, "\\"); + strcat(exclaim, finfo->name); - pstring partpath, ffname; - char *p=fname, *basehack; + if (clipfind(cliplist, clipn, exclaim)) { + DEBUG(3,("Skipping file %s\n", exclaim)); + return; + } + } - *partpath = 0; + if (finfo->mode & aDIR) + { + pstring saved_curdir; + pstring mtar_mask; + char *inbuf,*outbuf; - /* fname copied to ffname so can strtok */ + inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - strcpy(ffname, fname); + if (!inbuf || !outbuf) + { + DEBUG(0,("out of memory\n")); + return; + } - /* do a `basename' on ffname, so don't try and make file name directory */ - if ((basehack=strrchr(ffname, '\\')) == NULL) - return True; - else - *basehack='\0'; + strcpy(saved_curdir,cur_dir); - p=strtok(ffname, "\\"); + strcat(cur_dir,finfo->name); + strcat(cur_dir,"\\"); - while (p) + /* write a tar directory, don't bother with mode - just set it to + * 40755 */ + writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0"); + strcpy(mtar_mask,cur_dir); + strcat(mtar_mask,"*"); + + do_dir((char *)inbuf,(char *)outbuf,mtar_mask,attribute,do_tar,recurse); + strcpy(cur_dir,saved_curdir); + free(inbuf);free(outbuf); + } + else { - strcat(partpath, p); + strcpy(rname,cur_dir); + strcat(rname,finfo->name); + do_atar(rname,finfo->name,finfo); + } +} - if (!smbchkpath(partpath, inbuf, outbuf)) { - if (!smbmkdir(partpath, inbuf, outbuf)) - { - DEBUG(0, ("Error mkdirhiering\n")); - return False; - } - else - DEBUG(3, ("mkdirhiering %s\n", partpath)); +/**************************************************************************** +Convert from UNIX to DOS file names +***************************************************************************/ +static void unfixtarname(char *tptr, char *fp, int l) +{ + /* remove '.' from start of file name, convert from unix /'s to + * dos \'s in path. Kill any absolute path names. + */ - } + if (*fp == '.') fp++; + if (*fp == '\\' || *fp == '/') fp++; - strcat(partpath, "\\"); - p = strtok(NULL,"/\\"); +#ifdef KANJI + while (l > 0) { + if (is_shift_jis (*fp)) { + *tptr++ = *fp++; + *tptr++ = *fp++; + l -= 2; + } else if (is_kana (*fp)) { + *tptr++ = *fp++; + l--; + } else if (*fp == '/') { + *tptr++ = '\\'; + fp++; + l--; + } else { + *tptr++ = *fp++; + l--; } - - return True; + } +#else + while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; } +#endif } static void do_tarput() @@ -1114,8 +1206,10 @@ int nread=0, bufread; char *inbuf,*outbuf; int fsize=0; - + int fnum; struct timeval tp_start; + BOOL tskip=False; /* We'll take each file as it comes */ + GetTimeOfDay(&tp_start); inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); @@ -1129,16 +1223,47 @@ /* * Must read in tbufsiz dollops - * - this is crude as should detect */ - - while ((bufread=read(tarhandle, tarbuf, tbufsiz))) { + + /* These should be the only reads in clitar.c */ + while ((bufread=read(tarhandle, tarbuf, tbufsiz))>0) { char *bufferp, *endofbuffer; - int chunk, fnum; - + int chunk; + + /* Code to handle a short read. + * We always need a TBLOCK full of stuff + */ + if (bufread % TBLOCK) { + int lchunk=TBLOCK-(bufread % TBLOCK); + int lread; + + /* It's a shorty - a short read that is */ + DEBUG(3, ("Short read, read %d so far (need %d)\n", bufread, lchunk)); + + while ((lread=read(tarhandle, tarbuf+bufread, lchunk))>0) { + bufread+=lread; + if (!(lchunk-=lread)) break; + } + + /* If we've reached EOF then that must be a short file */ + if (lread<=0) break; + } + bufferp=tarbuf; endofbuffer=tarbuf+bufread; - + + if (tskip) { + if (fsize<bufread) { + tskip=False; + bufferp+=fsize; + fsize=0; + } else { + if (fsize==bufread) tskip=False; + fsize-=bufread; + continue; + } + } + do { if (!fsize) { @@ -1162,6 +1287,25 @@ break; } + tskip=clipn + && (clipfind(cliplist, clipn, finfo.name) ^ tar_excl); + if (tskip) { + bufferp+=TBLOCK; + if (finfo.mode & aDIR) + continue; + else if ((fsize=finfo.size) % TBLOCK) { + fsize+=TBLOCK-(fsize%TBLOCK); + } + if (fsize<endofbuffer-bufferp) { + bufferp+=fsize; + fsize=0; + continue; + } else { + fsize-=endofbuffer-bufferp; + break; + } + } + if (finfo.mode & aDIR) { if (!smbchkpath(finfo.name, inbuf, outbuf) @@ -1187,13 +1331,13 @@ free(inbuf);free(outbuf); return; } - + DEBUG(0,("restore tar file %s of size %d bytes\n", finfo.name,finfo.size)); nread=0; if ((bufferp+=TBLOCK) >= endofbuffer) break; - } /* if nread */ + } /* if (!fsize) */ /* write out the file in chunk sized chunks - don't * go past end of buffer though */ @@ -1238,20 +1382,20 @@ } } while (bufferp < endofbuffer); } - if (ntarf) - DEBUG(0, ("premature eof on tar file ?\n")); - else - DEBUG(0,("total of %d tar files restored to share\n", ntarf)); - + + DEBUG(0, ("premature eof on tar file ?\n")); + DEBUG(0,("total of %d tar files restored to share\n", ntarf)); + free(inbuf); free(outbuf); } /* - * samba commands + * samba interactive commands */ -/* blocksize command */ - +/**************************************************************************** +Blocksize command +***************************************************************************/ void cmd_block(void) { fstring buf; @@ -1274,6 +1418,9 @@ DEBUG(2,("blocksize is now %d\n", blocksize)); } +/**************************************************************************** +command to set incremental / reset mode +***************************************************************************/ void cmd_tarmode(void) { fstring buf; @@ -1295,8 +1442,9 @@ tar_reset ? "reset" : "noreset")); } -/* freebie crude attrib command */ - +/**************************************************************************** +Feeble attrib command +***************************************************************************/ void cmd_setmode(void) { char *q; @@ -1349,93 +1497,217 @@ (void) do_setrattr(fname, attra[ATTRRESET], ATTRRESET); } -/* - * do a tar command - */ - +/**************************************************************************** +Principal command for creating / extracting +***************************************************************************/ void cmd_tar(char *inbuf, char *outbuf) { - int attribute = aDIR | aSYSTEM | aHIDDEN; - pstring ffname, tarmac; fstring buf; - char *p = buf; + char **argl; + int argcl; if (!next_token(NULL,buf,NULL)) { - DEBUG(0,("tar [c|x] <filename>\n")); + DEBUG(0,("tar <c|x>[IXbga] <filename>\n")); return; } - if (*p == 'c') { - if (!next_token(NULL,buf,NULL)) - { - DEBUG(0,("tar [c|x] <filename> [<tar mask>]\n")); - return; - } - - strcpy(ffname,p); - - if(!strcmp(ffname,"-")) - tarhandle = fileno(stdout); - else - tarhandle = creat(ffname,0644); - - if (tarhandle < 0) - { - DEBUG(0,("Error opening local file %s\n",ffname)); - return; - } - - initarbuf(); + argl=toktocliplist(&argcl, NULL); + if (!tar_parseargs(argcl, argl, buf, 0)) + return; + + process_tar(inbuf, outbuf); + + free(argl); +} + +/**************************************************************************** +Command line (option) version +***************************************************************************/ +int process_tar(char *inbuf, char *outbuf) +{ + initarbuf(); + switch(tar_type) { + case 'x': + do_tarput(); + free(tarbuf); + close(tarhandle); + break; + case 'r': + case 'c': + if (clipn && tar_excl) { + int i; + pstring tarmac; - strcpy(tarmac,cur_dir); - if (next_token(NULL,buf,NULL)) - do { - if(tarmac[strlen(tarmac)-1]!='\\') - strcat(tarmac,"\\"); + for (i=0; i<clipn; i++) { + DEBUG(0,("arg %d = %s\n", i, cliplist[i])); + + if (*(cliplist[i]+strlen(cliplist[i])-1)=='\\') { + *(cliplist[i]+strlen(cliplist[i])-1)='\0'; + } - if (*p == '\\') - strcpy(tarmac,p); - else - strcat(tarmac,p); - } while (next_token(NULL,buf,NULL)); - else - strcat(tarmac,"*.*"); - - do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse); + if (strrchr(cliplist[i], '\\')) { + pstring saved_dir; + + strcpy(saved_dir, cur_dir); + + if (*cliplist[i]=='\\') { + strcpy(tarmac, cliplist[i]); + } else { + strcpy(tarmac, cur_dir); + strcat(tarmac, cliplist[i]); + } + strcpy(cur_dir, tarmac); + *(strrchr(cur_dir, '\\')+1)='\0'; + + do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse); + strcpy(cur_dir,saved_dir); + } else { + strcpy(tarmac, cur_dir); + strcat(tarmac, cliplist[i]); + do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse); + } + } + } else { + pstring mask; + strcpy(mask,cur_dir); + strcat(mask,"\\*"); + do_dir((char *)inbuf,(char *)outbuf,mask,attribute,do_tar,recurse); + } if (ntarf) dotareof(tarhandle); close(tarhandle); free(tarbuf); DEBUG(0, ("tar: dumped %d tar files\n", ntarf)); + break; } - else if (*p=='x') { - if (!next_token(NULL,buf,NULL)) - { - DEBUG(0,("tar [c|x] <filename> [<tar mask>]\n")); - return; + + return(0); +} + +/**************************************************************************** +Find a token (filename) in a clip list +***************************************************************************/ +int clipfind(char **aret, int ret, char *tok) +{ + if (aret==NULL) return 0; + + /* ignore leading slashes or dots in token */ + while(strchr("/\\.", *tok)) tok++; + + while(ret--) { + char *pkey=*aret++; + + /* ignore leading slashes or dots in list */ + while(strchr("/\\.", *pkey)) pkey++; + + if (!strslashcmp(pkey, tok)) return 1; + } + + return 0; +} + +/**************************************************************************** +Parse tar arguments. Sets tar_type, tar_excl, etc. +***************************************************************************/ +int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) +{ + char tar_clipfl='\0'; + + /* Reset back to defaults - could be from interactive version + * reset mode and archive mode left as they are though + */ + tar_type='\0'; + tar_excl=True; + + while (*Optarg) + switch(*Optarg++) { + case 'c': + tar_type='c'; + break; + case 'x': + if (tar_type=='c') { + printf("Tar must be followed by only one of c or x.\n"); + return 0; } - - strcpy(ffname,p); - - if(!strcmp(ffname,"-")) - tarhandle = fileno(stdin); - else - if ((tarhandle = open(ffname,O_RDONLY)) == -1) - { - DEBUG(0,("Error opening local file %s\n",ffname)); - return; + tar_type='x'; + break; + case 'b': + if (Optind>=argc || !(blocksize=atoi(argv[Optind]))) { + DEBUG(0,("Option b must be followed by valid blocksize\n")); + return 0; + } else { + Optind++; + } + break; + case 'g': + tar_inc=True; + break; + case 'N': + if (Optind>=argc) { + DEBUG(0,("Option N must be followed by valid file name\n")); + return 0; + } else { + struct stat stbuf; + extern time_t newer_than; + + if (sys_stat(argv[Optind], &stbuf) == 0) { + newer_than = stbuf.st_mtime; + DEBUG(1,("Getting files newer than %s", + asctime(LocalTime(&newer_than,GMT_TO_LOCAL)))); + Optind++; + } else { + DEBUG(0,("Error setting newer-than time\n")); + return 0; } + } + break; + case 'a': + tar_reset=True; + break; + case 'I': + if (tar_clipfl) { + DEBUG(0,("Only one of I,X must be specified\n")); + return 0; + } + tar_clipfl='I'; + break; + case 'X': + if (tar_clipfl) { + DEBUG(0,("Only one of I,X must be specified\n")); + return 0; + } + tar_clipfl='X'; + break; + default: + DEBUG(0,("Unknown tar option\n")); + return 0; + } - initarbuf(); + if (!tar_type) { + printf("Option T must be followed by one of c or x.\n"); + return 0; + } - do_tarput(); + if (Optind>=argc || !strcmp(argv[Optind], "-")) { + /* Sets tar handle to either 0 or 1, as appropriate */ + tarhandle=(tar_type=='c'); + } else { + tar_excl=tar_clipfl!='X'; + + if (Optind+1<argc) { + cliplist=argv+Optind+1; + clipn=argc-Optind-1; + } - free(tarbuf); - close(tarhandle); + if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1) + || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0)) + { + DEBUG(0,("Error opening local file %s\n",argv[Optind])); + return(0); + } } - else - DEBUG(0,("tar [c|x] <filename>\n")); -} + return 1; +} diff -u -r --new-file last-version/source/includes.h samba-1.9.16alpha1/source/includes.h --- last-version/source/includes.h Mon Jan 15 19:15:36 1996 +++ samba-1.9.16alpha1/source/includes.h Thu Feb 29 00:12:08 1996 @@ -104,6 +104,10 @@ #define NO_NETIFH #endif +#ifdef LYNX +#define NO_SYSMOUNTH +#endif + #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH)) #define PASSWORD_LENGTH 16 @@ -196,6 +200,16 @@ /* this might be different on different systems */ #ifdef QUOTAS +#ifdef LINUX +#ifdef __KERNEL__ +#undef __KERNEL__ +#include <sys/quota.h> +#define __KERNEL__ +#else +#include <sys/quota.h> +#endif +#include <mntent.h> +#else #include <sys/quota.h> #ifndef CRAY #include <devnm.h> @@ -203,6 +217,7 @@ #include <mntent.h> #endif #endif +#endif #ifdef SYSLOG #include <syslog.h> @@ -393,6 +408,7 @@ #define SIGNAL_CAST (void (*)(int)) #define USE_STATVFS #define USE_GETCWD +#define USE_SETSID #endif @@ -415,6 +431,7 @@ #include <prot.h> #include <unistd.h> #define PASSWORD_LENGTH 16 +#define NEED_AUTH_PARAMETERS #endif /* OSF1_ENH_SEC */ #endif @@ -494,6 +511,11 @@ #include <sys/types.h> #include <sys/termios.h> #include <netinet/tcp.h> +#ifdef HPUX_10_TRUSTED +#include <hpsecurity.h> +#include <prot.h> +#define NEED_AUTH_PARAMETERS +#endif #define SIGNAL_CAST (void (*)(__harg)) #define SELECT_CAST (int *) #define SYSV @@ -555,6 +577,7 @@ #define gid_t int #define SIGNAL_CAST (void (*)(int)) #define WAIT3_CAST1 (union wait *) +#define HAVE_GMTOFF #endif @@ -765,9 +788,7 @@ #define gid_t int #define mode_t int #define ptrdiff_t int - #define HAVE_GETGRNAM 0 - #define NO_EID #define NO_FSYNC #define NO_FTRUNCATE @@ -834,9 +855,28 @@ #endif +#ifdef LYNX +#define SIGNAL_CAST (void (*)()) +#define WAIT3_CAST1 (union wait *) +#define STATFS4 +#include <fcntl.h> +#include <resource.h> +#include <stat.h> +#include <string.h> +#include <dirent.h> +#include <sys/statfs.h> +#define USE_GETCWD +#define USE_GETSID +#endif + + /******************************************************************* end of the platform specific sections ********************************************************************/ + +#ifdef SecureWare +#define NEED_AUTH_PARAMETERS +#endif #ifdef REPLACE_GETPASS extern char *getsmbpass(char *); diff -u -r --new-file last-version/source/installman.sh samba-1.9.16alpha1/source/installman.sh --- last-version/source/installman.sh Sat Nov 18 20:36:53 1995 +++ samba-1.9.16alpha1/source/installman.sh Sat Feb 24 19:04:53 1996 @@ -1,5 +1,6 @@ #!/bin/sh MANDIR=$1 +SRCDIR=$2 echo Installing man pages in $MANDIR @@ -13,10 +14,11 @@ fi done -cp ../docs/*.1 $MANDIR/man1 -cp ../docs/*.5 $MANDIR/man5 -cp ../docs/*.8 $MANDIR/man8 -cp ../docs/*.7 $MANDIR/man7 +cp $SRCDIR../docs/*.1 $MANDIR/man1 +cp $SRCDIR../docs/*.5 $MANDIR/man5 +cp $SRCDIR../docs/*.8 $MANDIR/man8 +cp $SRCDIR../docs/*.7 $MANDIR/man7 +echo Setting permissions on man pages chmod 0644 $MANDIR/man1/smbstatus.1 chmod 0644 $MANDIR/man1/smbclient.1 chmod 0644 $MANDIR/man1/smbrun.1 @@ -28,5 +30,6 @@ chmod 0644 $MANDIR/man8/smbd.8 chmod 0644 $MANDIR/man8/nmbd.8 +echo Man pages installed exit 0 diff -u -r --new-file last-version/source/ipc.c samba-1.9.16alpha1/source/ipc.c --- last-version/source/ipc.c Mon Jan 15 16:24:54 1996 +++ samba-1.9.16alpha1/source/ipc.c Sun Feb 25 13:10:25 1996 @@ -35,6 +35,7 @@ extern int DEBUGLEVEL; extern int maxxmit; extern files_struct Files[]; +extern connection_struct Connections[]; extern fstring local_machine; @@ -417,7 +418,6 @@ PACK(desc,t,v); } - static void PackDriverData(struct pack_desc* desc) { char drivdata[4+4+32]; @@ -667,7 +667,7 @@ return False; queuecnt = 0; for (i = 0; i < services; i++) - if (lp_print_ok(i) && lp_browseable(i)) + if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) queuecnt++; if (uLevel > 0) { queue = (print_queue_struct**)malloc(queuecnt*sizeof(print_queue_struct*)); @@ -678,7 +678,7 @@ subcnt = 0; n = 0; for (i = 0; i < services; i++) - if (lp_print_ok(i) && lp_browseable(i)) { + if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) { subcntarr[n] = get_printqueue(i,cnum,&queue[n],&status[n]); subcnt += subcntarr[n]; n++; @@ -692,7 +692,7 @@ n = 0; succnt = 0; for (i = 0; i < services; i++) - if (lp_print_ok(i) && lp_browseable(i)) { + if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) { fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]); n++; if (desc.errcode == NERR_Success) succnt = n; @@ -737,19 +737,58 @@ return True; } -struct server_info_struct { +/* used for server information: client, nameserv and ipc */ +struct srv_info_struct +{ fstring name; uint32 type; fstring comment; + fstring domain; /* used ONLY in ipc.c NOT namework.c */ + BOOL server_added; /* used ONLY in ipc.c NOT namework.c */ }; +/******************************************************************* + filter out unwanted server info + ******************************************************************/ +static BOOL filter_server_info(struct srv_info_struct *server, + char *domain) +{ + if (*domain) + return(strequal(domain, server->domain)); + + return (True); /* be indiscriminate: get all servers! */ +} + +/******************************************************************* + find server in the files saved by nmbd. Return True if we find it. + ******************************************************************/ +static BOOL find_server(struct srv_info_struct *servers, int num_servers, + char *domain, char *name) +{ + int count; + + if (!servers || num_servers == 0) return (False); + + for (count = 0; count < num_servers; count++) { + struct srv_info_struct *s; + + s = &servers[count]; + + if (strequal(name, s->name)) { + StrnCpy(domain, s->domain, sizeof(pstring)-1); + return (True); + } + } + return (False); +} + /******************************************************************* get server info lists from the files saved by nmbd. Return the number of entries ******************************************************************/ -static int get_server_info(uint32 servertype, - struct server_info_struct **servers) +static int get_server_info(uint32 servertype, + struct srv_info_struct **servers) { FILE *f; pstring fname; @@ -768,35 +807,48 @@ DEBUG(4,("Can't open %s - %s\n",fname,strerror(errno))); return(0); } + if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM; - if (servertype == SV_TYPE_ALL) - servertype &= ~SV_TYPE_DOMAIN_ENUM; - - while (!feof(f)) { + while (!feof(f)) + { fstring stype; - struct server_info_struct *s; + struct srv_info_struct *s; char *ptr = line; *ptr = 0; + fgets(line,sizeof(line)-1,f); if (!*line) continue; if (count == alloced) { alloced += 10; - (*servers) = (struct server_info_struct *) + (*servers) = (struct srv_info_struct *) Realloc(*servers,sizeof(**servers)*alloced); if (!(*servers)) return(0); bzero((char *)((*servers)+count),sizeof(**servers)*(alloced-count)); } s = &(*servers)[count]; - if (!next_token(&ptr,s->name,NULL)) continue; - if (!next_token(&ptr,stype,NULL)) continue; - if (!next_token(&ptr,s->comment,NULL)) continue; + s->server_added = True; + + if (!next_token(&ptr,s->name , NULL)) continue; + if (!next_token(&ptr,stype , NULL)) continue; + if (!next_token(&ptr,s->comment, NULL)) continue; + if (!next_token(&ptr,s->domain , NULL)) { + /* this allows us to cop with an old nmbd */ + strcpy(s->domain,my_workgroup()); + } + if (sscanf(stype,"%X",&s->type) != 1) continue; - if (!(servertype & s->type) || - ((s->type&SV_TYPE_DOMAIN_ENUM) && - !(servertype&SV_TYPE_DOMAIN_ENUM))) continue; + /* doesn't match up: don't want it */ + if (!(servertype & s->type)) continue; + + /* server entry is a domain, we haven't asked for domains: don't want it */ + if ((s->type&SV_TYPE_DOMAIN_ENUM) && !(servertype&SV_TYPE_DOMAIN_ENUM)) + continue; + + DEBUG(4,("Server %20s %8x %25s %15s\n", + s->name, stype, s->comment, s->domain)); count++; } @@ -808,9 +860,9 @@ /******************************************************************* fill in a server info structure ******************************************************************/ -static int fill_server_info(struct server_info_struct *service, - int uLevel,char **buf, int *buflen, - char **stringbuf, int *stringspace, char *baseaddr) +static int fill_srv_info(struct srv_info_struct *service, + int uLevel, char **buf, int *buflen, + char **stringbuf, int *stringspace, char *baseaddr) { int struct_len; char* p; @@ -888,10 +940,9 @@ view list of servers available (or possibly domains). The info is extracted from lists saved by nmbd on the local host ****************************************************************************/ -static BOOL api_RNetServerEnum(int cnum,int uid, char *param,char *data, - int mdrcnt,int mprcnt, - char **rdata,char **rparam, - int *rdata_len,int *rparam_len) +static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data, + int mdrcnt, int mprcnt, char **rdata, + char **rparam, int *rdata_len, int *rparam_len) { char *str1 = param+2; char *str2 = skip_string(str1,1); @@ -902,37 +953,81 @@ char *p2; int data_len, fixed_len, string_len; int f_len, s_len; - struct server_info_struct *servers=NULL; + struct srv_info_struct *servers=NULL; int counted=0,total=0; int i; + fstring domain; + BOOL domain_request = (servertype & SV_TYPE_DOMAIN_ENUM) && + !(servertype == SV_TYPE_ALL); + + domain[0] = 0; + p += 8; if (!prefix_ok(str1,"WrLehD")) return False; if (!check_server_info(uLevel,str2)) return False; + DEBUG(4, ("server request level: %s\n", str2)); + + if (strcmp(str1, "WrLehDO") == 0) + { + /* asking for servers. we will have to work out which workgroup was + requested, as we maintain lists for multiple workgroups */ + } + else if (strcmp(str1, "WrLehDz") == 0) + { + /* asking for a specific workgroup */ + StrnCpy(domain, p, sizeof(fstring)-1); + } + if (lp_browse_list()) + { total = get_server_info(servertype,&servers); + } + + if (!domain[0] && !domain_request) { + extern fstring remote_machine; + /* must be a server request with an assumed domain. find a domain */ + + if (find_server(servers, total, domain, remote_machine)) { + DEBUG(4, ("No domain specified: using %s for %s\n", + domain, remote_machine)); + } else { + /* default to soemthing sensible */ + strcpy(domain,my_workgroup()); + } + } data_len = fixed_len = string_len = 0; - for (i=0;i<total;i++) { - data_len += fill_server_info(&servers[i],uLevel,0,&f_len,0,&s_len,0); - if (data_len <= buf_len) { - counted++; - fixed_len += f_len; - string_len += s_len; + for (i=0;i<total;i++) + if (filter_server_info(&servers[i],domain)) { + data_len += fill_srv_info(&servers[i],uLevel,0,&f_len,0,&s_len,0); + if (data_len <= buf_len) + { + counted++; + fixed_len += f_len; + string_len += s_len; + } } - } *rdata_len = fixed_len + string_len; *rdata = REALLOC(*rdata,*rdata_len); bzero(*rdata,*rdata_len); - p2 = (*rdata) + fixed_len; /* auxillery data (strings) will go here */ + p2 = (*rdata) + fixed_len; /* auxilliary data (strings) will go here */ p = *rdata; f_len = fixed_len; s_len = string_len; - for (i = 0; i < counted;i++) - fill_server_info(&servers[i],uLevel,&p,&f_len,&p2,&s_len,*rdata); + + { + int count2 = counted; + for (i = 0; i < total && count2;i++) { + if (filter_server_info(&servers[i],domain)) { + fill_srv_info(&servers[i],uLevel,&p,&f_len,&p2,&s_len,*rdata); + count2--; + } + } + } *rparam_len = 8; *rparam = REALLOC(*rparam,*rparam_len); @@ -943,13 +1038,13 @@ if (servers) free(servers); - DEBUG(4,("NetServerEnum uLevel=%d counted=%d total=%d\n",uLevel,counted,total)); + DEBUG(3,("NetServerEnum domain = %s uLevel=%d counted=%d total=%d\n", + domain,uLevel,counted,total)); return(True); } - /**************************************************************************** get info about a share ****************************************************************************/ @@ -1125,7 +1220,7 @@ data_len = fixed_len = string_len = 0; for (i=0;i<count;i++) - if (lp_browseable(i)) + if (lp_browseable(i) && lp_snum_ok(i)) { total++; data_len += fill_share_info(cnum,i,uLevel,0,&f_len,0,&s_len,0); @@ -1145,7 +1240,7 @@ f_len = fixed_len; s_len = string_len; for (i = 0; i < count;i++) - if (lp_browseable(i)) + if (lp_browseable(i) && lp_snum_ok(i)) if (fill_share_info(cnum,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0) break; @@ -1555,7 +1650,7 @@ p += 16; if (uLevel > 0) { - struct server_info_struct *servers=NULL; + struct srv_info_struct *servers=NULL; int i,count; pstring comment; uint32 servertype=SV_TYPE_SERVER_UNIX|SV_TYPE_WORKSTATION| @@ -1721,44 +1816,56 @@ SCVAL(p,21,0); *p2 = 0; if (uLevel >= 10) { - SIVAL(p,22,PTR_DIFF(p2,*rdata)); /* comment */ - SIVAL(p,26,PTR_DIFF(p2,*rdata)); /* user_comment */ - SIVAL(p,30,PTR_DIFF(p2,*rdata)); /* full name */ - p2++; + SIVAL(p,22,PTR_DIFF(p2,p)); /* comment */ + strcpy(p2,"<Comment>"); + p2 = skip_string(p2,1); + SIVAL(p,26,PTR_DIFF(p2,p)); /* user_comment */ + strcpy(p2,"<UserComment>"); + p2 = skip_string(p2,1); + SIVAL(p,30,PTR_DIFF(p2,p)); /* full name */ + strcpy(p2,"<FullName>"); + p2 = skip_string(p2,1); } - if (uLevel == 11) { - SSVAL(p,34,USER_PRIV_ADMIN); /* user privilege */ + if (uLevel == 11) { /* modelled after NTAS 3.51 reply */ + SSVAL(p,34,USER_PRIV_USER); /* user privilege */ SIVAL(p,36,0); /* auth flags */ - SIVAL(p,40,0); /* password age */ - SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */ - strcpy(p2,"Y:\\GIGA\\C$\\PRJ\\USERS\\AD"); + SIVALS(p,40,-1); /* password age */ + SIVAL(p,44,PTR_DIFF(p2,p)); /* home dir */ + strcpy(p2,"\\\\%L\\HOMES"); + standard_sub_basic(p2); p2 = skip_string(p2,1); - SIVAL(p,48,PTR_DIFF(p2,*rdata)); /* parms */ + SIVAL(p,48,PTR_DIFF(p2,p)); /* parms */ strcpy(p2,""); p2 = skip_string(p2,1); SIVAL(p,52,0); /* last logon */ SIVAL(p,56,0); /* last logoff */ SSVALS(p,60,-1); /* bad pw counts */ SSVALS(p,62,-1); /* num logons */ - SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* logon server */ - strcpy(p2,"\\\\GIGA"); + SIVAL(p,64,PTR_DIFF(p2,p)); /* logon server */ + strcpy(p2,"\\\\*"); + p2 = skip_string(p2,1); + SSVAL(p,68,0); /* country code */ + + SIVAL(p,70,PTR_DIFF(p2,p)); /* workstations */ + strcpy(p2,""); p2 = skip_string(p2,1); - SSVAL(p,68,49); /* country code */ - SIVAL(p,70,0); /* workstations */ SIVALS(p,74,-1); /* max storage */ SSVAL(p,78,168); /* units per week */ - SIVAL(p,80,PTR_DIFF(p2,*rdata)); /* logon hours */ + SIVAL(p,80,PTR_DIFF(p2,p)); /* logon hours */ memset(p2,-1,21); - p2 += 21; - SSVAL(p,84,860); /* code page */ + SCVAL(p2,21,0); /* fix zero termination */ + p2 = skip_string(p2,1); + + SSVAL(p,84,0); /* code page */ } if (uLevel == 1 || uLevel == 2) { memset(p+22,' ',16); /* password */ SIVALS(p,38,-1); /* password age */ SSVAL(p,42,USER_PRIV_ADMIN); /* user privilege */ SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */ - strcpy(p2,"\\\\__SAMBA__\\HOMES"); + strcpy(p2,"\\\\%L\\HOMES"); + standard_sub_basic(p2); p2 = skip_string(p2,1); SIVAL(p,48,PTR_DIFF(p2,*rdata)); /* comment */ *p2++ = 0; @@ -1785,7 +1892,8 @@ SSVALS(p,102,-1); /* bad_pw_count */ SSVALS(p,104,-1); /* num_logons */ SIVAL(p,106,PTR_DIFF(p2,*rdata)); /* logon_server */ - strcpy(p2,"\\\\__SAMBA__"); + strcpy(p2,"\\\\%L"); + standard_sub_basic(p2); p2 = skip_string(p2,1); SSVAL(p,110,49); /* country_code */ SSVAL(p,112,860); /* code page */ @@ -1878,12 +1986,15 @@ desc.buflen = mdrcnt; desc.subformat = NULL; desc.format = str2; + + if (init_package(&desc,1,0)) { PACKI(&desc,"W",0); /* code */ PACKS(&desc,"B21",name); /* eff. name */ PACKS(&desc,"B",""); /* pad */ - PACKI(&desc,"W",2); /* priv */ + PACKI(&desc,"W", + Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER); PACKI(&desc,"D",0); /* auth flags XXX */ PACKI(&desc,"W",0); /* num logons */ PACKI(&desc,"W",0); /* bad pw count */ @@ -2218,7 +2329,7 @@ queuecnt = 0; for (i = 0; i < services; i++) - if (lp_print_ok(i) && lp_browseable(i)) + if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) queuecnt++; if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt); @@ -2228,7 +2339,7 @@ succnt = 0; n = 0; for (i = 0; i < services; i++) { - if (lp_print_ok(i) && lp_browseable(i)) { + if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) { fill_printdest_info(cnum,i,uLevel,&desc); n++; if (desc.errcode == NERR_Success) succnt = n; diff -u -r --new-file last-version/source/loadparm.c samba-1.9.16alpha1/source/loadparm.c --- last-version/source/loadparm.c Mon Jan 15 19:11:08 1996 +++ samba-1.9.16alpha1/source/loadparm.c Sat Feb 10 11:00:47 1996 @@ -605,6 +605,10 @@ string_initial(&sDefault.szLpqcommand,"lpstat -o%p"); string_initial(&sDefault.szLprmcommand,"cancel %p-%j"); string_initial(&sDefault.szPrintcommand,"lp -c -d%p %s; rm %s"); +#ifdef SVR4 + string_initial(&sDefault.szLppausecommand,"lp -i %p-%j -H hold"); + string_initial(&sDefault.szLpresumecommand,"lp -i %p-%j -H resume"); +#endif break; case PRINT_QNX: diff -u -r --new-file last-version/source/local.h samba-1.9.16alpha1/source/local.h --- last-version/source/local.h Tue Jan 16 20:26:37 1996 +++ samba-1.9.16alpha1/source/local.h Fri Jan 19 20:01:17 1996 @@ -133,7 +133,7 @@ #define SMBD_RELOAD_CHECK (10) #define SHARE_MODES_CHECK (10) #define SHARE_MODES_CLEAN (300) -#define IDLE_CLOSED_TIMEOUT (30) +#define IDLE_CLOSED_TIMEOUT (60) #define DPTR_IDLE_TIMEOUT (120) #define SMBD_SELECT_LOOP (10) #define NMBD_SELECT_LOOP (10) diff -u -r --new-file last-version/source/nameserv.c samba-1.9.16alpha1/source/nameserv.c --- last-version/source/nameserv.c Mon Jan 15 18:38:56 1996 +++ samba-1.9.16alpha1/source/nameserv.c Thu Feb 29 00:12:08 1996 @@ -186,11 +186,11 @@ ****************************************************************************/ static void fault_continue(void) { - static int errcount=0; + static int errcount=1; - errcount++; + errcount--; - if (is_daemon && errcount<100) + if (is_daemon && errcount) process(); #if DUMP_CORE @@ -200,6 +200,21 @@ return; } + +/******************************************************************* + wrapper to get the DC + ******************************************************************/ +static char *domain_controller(void) +{ + char *dc = lp_domain_controller(); + /* so many people mistake this for a bool that we need to handle it. sigh. */ + if (!*dc || strequal(dc,"yes") || strequal(dc,"true")) + strcpy(dc,myname); + return(dc); +} + + + /**************************************************************************** true if two netbios names are equal ****************************************************************************/ @@ -515,8 +530,8 @@ fclose(f); - unlink(fname); chmod(fnamenew,0644); + /* unlink(fname); */ rename(fnamenew,fname); DEBUG(3,("Wrote browse list %s\n",fname)); } @@ -1000,16 +1015,18 @@ fstring pdcname; *pdcname = 0; + if (strequal(domain_controller(),myname)) return; + if (!AM_MASTER || (last && (t-last < 10*60))) return; last = t; - ip = *interpret_addr2(lp_domain_controller()); + ip = *interpret_addr2(domain_controller()); if (zero_ip(ip)) ip = bcast_ip; if (!name_query(ClientNMB,PrimaryGroup, 0x1b,False,False,ip,&pdc_ip,queue_packet)) { - DEBUG(2,("Failed to find PDC at %s\n",lp_domain_controller())); + DEBUG(2,("Failed to find PDC at %s\n",domain_controller())); return; } @@ -1036,7 +1053,7 @@ p = skip_string(p,1); send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf), - PrimaryGroup,myname,0x1b,0,pdc_ip,myip); + myname,PrimaryGroup,0x1b,0,pdc_ip,myip); } @@ -1289,11 +1306,9 @@ static void process_logon_packet(struct packet_struct *p,char *buf,int len) { char *logname,*q; - char *reply_name; - BOOL add_slashes = False; pstring outbuf; struct dgram_packet *dgram = &p->packet.dgram; - int code,reply_code; + int code; if (!lp_domain_logons()) { DEBUG(3,("No domain logons\n")); @@ -1304,6 +1319,9 @@ return; } + q = outbuf; + bzero(outbuf,sizeof(outbuf)); + code = SVAL(buf,0); switch (code) { case 0: @@ -1311,9 +1329,17 @@ char *machine = buf+2; char *user = skip_string(machine,1); logname = skip_string(user,1); - reply_code = 6; - reply_name = myname; - add_slashes = True; + + SSVAL(q,0,6); + q += 2; + strcpy(q,"\\\\"); + q += 2; + StrnCpy(q,myname,16); + strupper(q); + q = skip_string(q,1); + SSVAL(q,0,0xFFFF); + q += 2; + DEBUG(3,("Domain login request from %s(%s) user=%s\n", machine,inet_ntoa(p->ip),user)); } @@ -1322,12 +1348,17 @@ { char *machine = buf+2; logname = skip_string(machine,1); - reply_code = 7; - reply_name = lp_domain_controller(); - if (!*reply_name) { - DEBUG(3,("No domain controller configured\n")); - return; - } + + SSVAL(q,0,0xc); + q += 2; + StrnCpy(q,domain_controller(),16); + strupper(q); + q = skip_string(q,1); + q += PutUniCode(q,domain_controller()); + q += PutUniCode(q,dgram->dest_name.name); + SSVAL(q,0,0xFFFF); + q += 2; + DEBUG(3,("GETDC request from %s(%s)\n", machine,inet_ntoa(p->ip))); } @@ -1337,19 +1368,6 @@ return; } - bzero(outbuf,sizeof(outbuf)); - q = outbuf; - SSVAL(q,0,reply_code); - q += 2; - if (add_slashes) { - strcpy(q,"\\\\"); - q += 2; - } - StrnCpy(q,reply_name,16); - strupper(q); - q = skip_string(q,1); - SSVAL(q,0,0xFFFF); - q += 2; send_mailslot_reply(logname,ClientDGRAM,outbuf,PTR_DIFF(q,outbuf), myname,&dgram->source_name.name[0],0,0,p->ip,myip); @@ -1446,7 +1464,7 @@ } /* if I have a domain controller then announce to it */ - if (AM_MASTER && *lp_domain_controller()) + if (AM_MASTER) announce_master(PrimaryGroup); needannounce=False; @@ -2112,6 +2130,12 @@ strcpy(myname,myhostname); p = strchr(myname,'.'); if (p) *p = 0; + } + + { + extern fstring local_machine; + strcpy(local_machine,myname); + strupper(local_machine); } return True; diff -u -r --new-file last-version/source/nmbsync.c samba-1.9.16alpha1/source/nmbsync.c --- last-version/source/nmbsync.c Wed Nov 22 18:16:20 1995 +++ samba-1.9.16alpha1/source/nmbsync.c Sun Feb 18 18:12:18 1996 @@ -186,7 +186,8 @@ uid = SVAL(inbuf,smb_uid); bzero(outbuf,smb_size); - set_message(outbuf,4,2 + strlen(service) + 1 + strlen(dev),True); + set_message(outbuf,4,2 + (2 + strlen(name) + 1 + strlen(service)) + + 1 + strlen(dev),True); CVAL(outbuf,smb_com) = SMBtconX; SSVAL(outbuf,smb_uid,uid); @@ -194,7 +195,10 @@ SSVAL(outbuf,smb_vwv3,1); p = smb_buf(outbuf) + 1; - strcpy(p,service); + strcpy(p, "\\\\"); + strcat(p, name); + strcat(p, "\\"); + strcat(p,service); p = skip_string(p,1); strcpy(p,dev); diff -u -r --new-file last-version/source/password.c samba-1.9.16alpha1/source/password.c --- last-version/source/password.c Mon Jan 15 13:04:50 1996 +++ samba-1.9.16alpha1/source/password.c Tue Jan 30 17:26:05 1996 @@ -737,6 +737,14 @@ } #endif +#ifdef HPUX_10_TRUSTED + { + struct pr_passwd *pr_pw = getprpwnam(pass->pw_name); + if (pr_pw && pr_pw->ufld.fd_encrypt) + pass->pw_passwd = pr_pw->ufld.fd_encrypt; + } +#endif + #ifdef OSF1_ENH_SEC { struct pr_passwd *mypasswd; diff -u -r --new-file last-version/source/printing.c samba-1.9.16alpha1/source/printing.c --- last-version/source/printing.c Mon Jan 15 12:29:51 1996 +++ samba-1.9.16alpha1/source/printing.c Wed Jan 31 21:18:37 1996 @@ -488,18 +488,19 @@ here is an example of "lpstat -o dcslw" output under sysv dcslw-896 tridge 4712 Dec 20 10:30:30 on dcslw +dcslw-897 tridge 4712 Dec 20 10:30:30 being held ****************************************************************************/ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first) { - string tok[8]; + string tok[9]; int count=0; char *p; /* handle the dash in the job id */ string_sub(line,"-"," "); - for (count=0; count<8 && next_token(&line,tok[count],NULL); count++) ; + for (count=0; count<9 && next_token(&line,tok[count],NULL); count++) ; /* we must get 7 tokens */ if (count < 7) @@ -520,7 +521,12 @@ buf->job = atoi(tok[1]); buf->size = atoi(tok[3]); - buf->status = strequal(tok[7],"on")?LPQ_PRINTING:LPQ_QUEUED; + if (count > 7 && strequal(tok[7],"on")) + buf->status = LPQ_PRINTING; + else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held")) + buf->status = LPQ_PAUSED; + else + buf->status = LPQ_QUEUED; buf->priority = 0; buf->time = EntryTime(tok, 4, count, 7); StrnCpy(buf->user,tok[2],sizeof(buf->user)-1); diff -u -r --new-file last-version/source/reply.c samba-1.9.16alpha1/source/reply.c --- last-version/source/reply.c Tue Jan 16 20:28:29 1996 +++ samba-1.9.16alpha1/source/reply.c Thu Feb 29 00:19:48 1996 @@ -334,6 +334,11 @@ StrnCpy(smb_apasswd,p + passlen1,smb_apasslen); } } + if (passlen2 == 1) { + /* apparently NT sometimes sets passlen2 to 1 when it means 0. This + tries to work around that problem */ + passlen2 = 0; + } p += passlen1 + passlen2; strcpy(user,p); p = skip_string(p,1); DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s]\n", @@ -578,7 +583,7 @@ if (directory_exist(fname,NULL)) mode |= aDIR; if (check_name(fname,cnum)) - ok = (dos_chmod(cnum,fname,mode) == 0); + ok = (dos_chmod(cnum,fname,mode,NULL) == 0); if (ok) ok = set_filetime(fname,mtime); @@ -992,7 +997,7 @@ if (!check_name(fname,cnum)) return(UNIXERROR(ERRDOS,ERRnoaccess)); - unixmode = unix_mode(cnum,smb_attr); + unixmode = unix_mode(cnum,smb_attr | aARCH); open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode, &rmode,&smb_action); @@ -1564,7 +1569,7 @@ DEBUG(0,("couldn't seek to %d in writebraw\n",startpos)); if (numtowrite>0) - nwritten = write_data(Files[fnum].fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); DEBUG(3,("%s writebraw1 fnum=%d cnum=%d start=%d num=%d wrote=%d sync=%d\n", timestring(),fnum,cnum,startpos,numtowrite,nwritten,write_through)); @@ -1632,7 +1637,6 @@ int cnum,fnum; int nwritten = -1; int outsize = 0; - int fd; char *data; uint32 numtowrite,startpos; int eclass; @@ -1649,8 +1653,6 @@ startpos = IVAL(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - fd = Files[fnum].fd; - if (is_locked(fnum,cnum,numtowrite,startpos)) return(ERROR(ERRDOS,ERRlock)); @@ -1662,7 +1664,7 @@ if(numtowrite == 0) nwritten = 0; else - nwritten = write_data(fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); if (lp_syncalways(SNUM(cnum))) sync_file(fnum); @@ -1693,7 +1695,6 @@ int nwritten = -1; int outsize = 0; int startpos; - int fd; char *data; dum1 = dum2 = 0; @@ -1710,8 +1711,6 @@ startpos = IVAL(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - fd = Files[fnum].fd; - if (is_locked(fnum,cnum,numtowrite,startpos)) return(ERROR(ERRDOS,ERRlock)); @@ -1721,9 +1720,9 @@ zero then the file size should be extended or truncated to the size given in smb_vwv[2-3] */ if(numtowrite == 0) - nwritten = set_filelen(fd, startpos); + nwritten = set_filelen(Files[fnum].fd, startpos); else - nwritten = write_data(fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); if (lp_syncalways(SNUM(cnum))) sync_file(fnum); @@ -1761,7 +1760,6 @@ int cnum; int nwritten = -1; int outsize = 0; - int fd; char *data; cnum = SVAL(inbuf,smb_tid); @@ -1772,8 +1770,6 @@ data = smb_base(inbuf) + smb_doff; - fd = Files[fnum].fd; - if (is_locked(fnum,cnum,smb_dsize,smb_offs)) return(ERROR(ERRDOS,ERRlock)); @@ -1786,7 +1782,7 @@ if(smb_dsize == 0) nwritten = 0; else - nwritten = write_data(fd,data,smb_dsize); + nwritten = write_file(fnum,data,smb_dsize); if(((nwritten == 0) && (smb_dsize != 0))||(nwritten < 0)) return(UNIXERROR(ERRDOS,ERRnoaccess)); @@ -1974,7 +1970,7 @@ seek_file(fnum,startpos); - nwritten = write_data(Files[fnum].fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); close_file(fnum); @@ -2321,7 +2317,7 @@ numtowrite = SVAL(smb_buf(inbuf),1); data = smb_buf(inbuf) + 3; - if (write_data(Files[fnum].fd,data,numtowrite) != numtowrite) + if (write_file(fnum,data,numtowrite) != numtowrite) return(UNIXERROR(ERRDOS,ERRnoaccess)); DEBUG(3,("%s printwrite fnum=%d cnum=%d num=%d\n",timestring(),fnum,cnum,numtowrite)); @@ -2585,7 +2581,7 @@ { int Access,action; struct stat st; - int ret; + int ret=0; int fnum1,fnum2; pstring dest; @@ -2964,7 +2960,6 @@ int outsize = 0; int32 startpos; int tcount, write_through, smb_doff; - int fd; char *data; cnum = SVAL(inbuf,smb_tid); @@ -2986,13 +2981,11 @@ not an SMBwritebmpx - set this up now so we don't forget */ CVAL(outbuf,smb_com) = SMBwritec; - fd = Files[fnum].fd; - if (is_locked(fnum,cnum,tcount,startpos)) return(ERROR(ERRDOS,ERRlock)); seek_file(fnum,startpos); - nwritten = write_data(fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); if(lp_syncalways(SNUM(cnum)) || write_through) sync_file(fnum); @@ -3060,7 +3053,6 @@ int outsize = 0; int32 startpos; int tcount, write_through, smb_doff; - int fd; char *data; write_bmpx_struct *wbms; BOOL send_response = False; @@ -3093,10 +3085,8 @@ if(wbms->wr_discard) return -1; /* Just discard the packet */ - fd = Files[fnum].fd; - seek_file(fnum,startpos); - nwritten = write_data(fd,data,numtowrite); + nwritten = write_file(fnum,data,numtowrite); if(lp_syncalways(SNUM(cnum)) || write_through) sync_file(fnum); @@ -3186,7 +3176,7 @@ CHECK_ERROR(fnum); /* Do an fstat on this file */ - if(fstat( Files[fnum].fd, &sbuf)) + if(fstat(Files[fnum].fd, &sbuf)) return(UNIXERROR(ERRDOS,ERRnoaccess)); mode = dos_mode(cnum,Files[fnum].name,&sbuf); diff -u -r --new-file last-version/source/server.c samba-1.9.16alpha1/source/server.c --- last-version/source/server.c Mon Jan 15 13:08:53 1996 +++ samba-1.9.16alpha1/source/server.c Thu Feb 29 00:12:08 1996 @@ -211,18 +211,21 @@ /******************************************************************* chmod a file - but preserve some bits ********************************************************************/ -int dos_chmod(int cnum,char *fname,int dosmode) +int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st) { - struct stat st; + struct stat st1; int mask=0; int tmp; int unixmode; - if (sys_stat(fname,&st)) return(-1); + if (!st) { + st = &st1; + if (sys_stat(fname,st)) return(-1); + } - if (S_ISDIR(st.st_mode)) dosmode |= aDIR; + if (S_ISDIR(st->st_mode)) dosmode |= aDIR; - if (dos_mode(cnum,fname,&st) == dosmode) return(0); + if (dos_mode(cnum,fname,st) == dosmode) return(0); unixmode = unix_mode(cnum,dosmode); @@ -239,10 +242,10 @@ if (!MAP_SYSTEM(cnum)) mask |= S_IXGRP; if (!MAP_HIDDEN(cnum)) mask |= S_IXOTH; - unixmode |= (st.st_mode & mask); + unixmode |= (st->st_mode & mask); /* if we previously had any r bits set then leave them alone */ - if ((tmp = st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) { + if ((tmp = st->st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) { unixmode &= ~(S_IRUSR|S_IRGRP|S_IROTH); unixmode |= tmp; } @@ -250,7 +253,7 @@ /* if we previously had any w bits set then leave them alone if the new mode is not rdonly */ if (!IS_DOS_READONLY(dosmode) && - (tmp = st.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) { + (tmp = st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) { unixmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); unixmode |= tmp; } @@ -522,6 +525,96 @@ #ifdef QUOTAS +#ifdef LINUX +/**************************************************************************** +try to get the disk space from disk quotas (LINUX version) +****************************************************************************/ +/* +If you didn't make the symlink to the quota package, too bad :( +*/ +#include "quota/quotactl.c" +#include "quota/hasquota.c" +static BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize) +{ + uid_t euser_id; + struct dqblk D; + struct stat S; + dev_t devno ; + struct mntent *mnt; + FILE *fp; + int found ; + int qcmd, fd ; + char *qfpathname; + + /* find the block device file */ + + if ( stat(path, &S) == -1 ) + return(False) ; + + devno = S.st_dev ; + + fp = setmntent(MOUNTED,"r"); + found = False ; + + while ((mnt = getmntent(fp)) != (struct mntent *) 0) { + if ( stat(mnt->mnt_dir,&S) == -1 ) + continue ; + if (S.st_dev == devno) { + found = True ; + break ; + } + } + endmntent(fp) ; + + if ( ! found ) + return(False) ; + + qcmd = QCMD(Q_GETQUOTA, USRQUOTA); + + if (hasmntopt(mnt, MNTOPT_NOAUTO) || hasmntopt(mnt, MNTOPT_NOQUOTA)) + return(False) ; + + if (!hasquota(mnt, USRQUOTA, &qfpathname)) + return(False) ; + + euser_id = geteuid(); + seteuid(0); + + if (quotactl(qcmd, mnt->mnt_fsname, euser_id, (caddr_t)&D) != 0) { + if ((fd = open(qfpathname, O_RDONLY)) < 0) { + seteuid(euser_id); + return(False); + } + lseek(fd, (long) dqoff(euser_id), L_SET); + switch (read(fd, &D, sizeof(struct dqblk))) { + case 0:/* EOF */ + memset((caddr_t)&D, 0, sizeof(struct dqblk)); + break; + case sizeof(struct dqblk): /* OK */ + break; + default: /* ERROR */ + close(fd); + seteuid(euser_id); + return(False); + } + } + seteuid(euser_id); + *bsize=1024; + + if (D.dqb_bsoftlimit==0) + return(False); + if ((D.dqb_curblocks>D.dqb_bsoftlimit)||(D.dqb_curinodes>D.dqb_isoftlimit)) + { + *dfree = 0; + *dsize = D.dqb_curblocks; + } + else { + *dfree = D.dqb_bsoftlimit - D.dqb_curblocks; + *dsize = D.dqb_bsoftlimit; + } + return (True); +} +#else #ifndef CRAY /**************************************************************************** try to get the disk space from disk quotas @@ -670,6 +763,7 @@ } #endif /* CRAY */ +#endif /* LINUX */ #endif /* QUOTAS */ @@ -1014,6 +1108,7 @@ Files[fnum].share_mode = 0; Files[fnum].share_pending = False; Files[fnum].print_file = Connections[cnum].printer; + Files[fnum].modified = False; Files[fnum].cnum = cnum; string_set(&Files[fnum].name,fname); Files[fnum].wbmpx_ptr = NULL; @@ -1029,7 +1124,7 @@ Files[fnum].can_write) { DEBUG(3,("Writing postscript line\n")); - write_data(Files[fnum].fd,"%!\n",3); + write_file(fnum,"%!\n",3); } DEBUG(2,("%s %s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n", @@ -1132,6 +1227,16 @@ if (lp_share_modes(SNUM(cnum))) del_share_mode(fnum); + if (Files[fnum].modified) { + struct stat st; + if (fstat(Files[fnum].fd,&st) == 0) { + int dosmode = dos_mode(cnum,Files[fnum].name,&st); + if (!IS_DOS_ARCHIVE(dosmode)) { + dos_chmod(cnum,Files[fnum].name,dosmode | aARCH,&st); + } + } + } + close(Files[fnum].fd); /* NT uses smbclose to start a print - weird */ @@ -1151,12 +1256,29 @@ /******************************************************************* reproduce the share mode access table ********************************************************************/ -static int access_table(int new_deny,int old_deny,int old_mode) +static int access_table(int new_deny,int old_deny,int old_mode, + int share_pid,char *fname) { if (new_deny == DENY_ALL || old_deny == DENY_ALL) return(AFAIL); if (new_deny == DENY_DOS || old_deny == DENY_DOS) { + if (old_deny == new_deny && share_pid == getpid()) + return(AALL); + if (old_mode == 0) return(AREAD); + + /* the new smbpub.zip spec says that if the file extension is + .com, .dll, .exe or .sym then allow the open. I will force + it to read-only as this seems sensible although the spec is + a little unclear on this. */ + if ((fname = strrchr(fname,'.'))) { + if (strequal(fname,".com") || + strequal(fname,".dll") || + strequal(fname,".exe") || + strequal(fname,".sym")) + return(AREAD); + } + return(AFAIL); } @@ -1312,31 +1434,17 @@ return; } - /* C. Hoch 11/21/95 Handle DOS (compatibility) mode on the same machine. - * Any number of read and/or write opens in compatibility mode from the - * same machine are allowed. - * Also, read opens in compatibility mode from different machines - * are allowed, even if the file is already opened for read in some - * share mode. This is "soft compatibility" mode (Microsoft Knowledge Base, - * WfWG, "How VSHARE386 Manages File Sharing", Q90239), and is handled in - * access_table(). - */ - if ((deny_mode==DENY_DOS || old_deny_mode==DENY_DOS) && - share_pid == getpid()) { - if (old_deny_mode != deny_mode) { - DEBUG(2,("Share violation on file %s\n",fname)); - errno = EACCES; - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadshare; - return; - } - } else { - int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode); + { + int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode, + share_pid,fname); if ((access_allowed == AFAIL) || (access_allowed == AREAD && flags == O_WRONLY) || (access_allowed == AWRITE && flags == O_RDONLY)) { - DEBUG(2,("Share violation on file %s\n",fname)); + DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n", + deny_mode,old_deny_mode,old_open_mode, + share_pid,fname, + access_allowed)); errno = EACCES; unix_ERR_class = ERRDOS; unix_ERR_code = ERRbadshare; @@ -1362,7 +1470,7 @@ } if (Files[fnum].open) { - int open_mode; + int open_mode=0; switch (flags) { case O_RDONLY: open_mode = 0; @@ -1491,6 +1599,22 @@ } +/**************************************************************************** +write to a file +****************************************************************************/ +int write_file(int fnum,char *data,int n) +{ + if (!Files[fnum].can_write) { + errno = EPERM; + return(0); + } + + Files[fnum].modified = True; + + return(write_data(Files[fnum].fd,data,n)); +} + + static int old_umask = 022; /**************************************************************************** @@ -3354,6 +3478,7 @@ char *home = get_home_dir(Connections[cnum].user); if (home) string_sub(s,"%H",home); } + string_sub(s,"%g",gidtoname(Connections[cnum].gid)); } standard_sub_basic(s); } @@ -3994,13 +4119,12 @@ int opt; extern char *optarg; -#ifdef SecureWare +#ifdef NEED_AUTH_PARAMETERS set_auth_parameters(argc,argv); - setluid(0); #endif -#ifdef OSF1_ENH_SEC - set_auth_parameters(argc,argv); +#ifdef SecureWare + setluid(0); #endif append_log = True; diff -u -r --new-file last-version/source/smb.h samba-1.9.16alpha1/source/smb.h --- last-version/source/smb.h Mon Jan 15 14:14:46 1996 +++ samba-1.9.16alpha1/source/smb.h Thu Feb 29 00:12:08 1996 @@ -259,6 +259,7 @@ BOOL share_mode; BOOL share_pending; BOOL print_file; + BOOL modified; char *name; } files_struct; @@ -612,13 +613,13 @@ int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew); int smb_offset(char *p,char *buf); void sync_file(int fnum); -void PutUniCode(char *dst,char *src); +int PutUniCode(char *dst,char *src); void map_username(char *user); void close_low_fds(void); void clean_share_files(void); int write_socket(int fd,char *buf,int len); char *readdirname(void *p); -int dos_chmod(int cnum,char *fname,int mode); +int dos_chmod(int cnum,char *fname,int mode,struct stat *st); int smb_numwords(char *buf); int get_share_mode(int cnum,struct stat *sbuf,int *pid); void del_share_mode(int fnum); @@ -679,6 +680,7 @@ char *skip_string(char *buf,int n); BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset); int read_file(int fnum,char *data,int pos,int mincnt,int maxcnt,int timeout,BOOL exact); +int write_file(int fnum,char *data,int n); BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); int seek_file(int fnum,int pos); BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); diff -u -r --new-file last-version/source/smbencrypt.c samba-1.9.16alpha1/source/smbencrypt.c --- last-version/source/smbencrypt.c Sun Nov 5 15:46:54 1995 +++ samba-1.9.16alpha1/source/smbencrypt.c Thu Feb 29 00:12:08 1996 @@ -119,7 +119,7 @@ StrnCpy((char *)p14,(char *)passwd,14); strupper((char *)p14); - E_P16(p14, p21); + E_P16(p14, p21); E_P24(p21, c8, p24); } diff -u -r --new-file last-version/source/smbtar samba-1.9.16alpha1/source/smbtar --- last-version/source/smbtar Thu Jun 29 17:58:36 1995 +++ samba-1.9.16alpha1/source/smbtar Thu Feb 29 00:12:08 1996 @@ -1,87 +1,141 @@ #!/bin/sh -# - -# edit this to show where your smbclient is -SMBCLIENT="./smbclient" +# +# smbtar script - front end to smbclient +# +# Authors: Martin.Kraemer <Martin.Kraemer@mch.sni.de> +# and Ricky Poulten (ricky@logcam.co.uk) +# +# (May need to change shell to ksh for HPUX or OSF for better getopts) + +case $0 in + # when called by absolute path, assume smbclient is in the same directory + /*) + SMBCLIENT="`dirname $0`/smbclient";; + *) # edit this to show where your smbclient is + SMBCLIENT="./smbclient";; +esac +# These are the default values. You could fill them in if you know what +# you're doing, but beware: better not store a plain text password! server="" -service=backup +service="backup" # Default: a service called "backup" password="" -username=$LOGNAME -verbose="/dev/null" +username=$LOGNAME # Default: same user name as in *nix +verbose="2>/dev/null" # Default: no echo to stdout log="-d 2" newer="" blocksize="" -tarcmd="tar c" -TF=${TAPE-tar.out} +tarcmd="c" +tarargs="" +cdcmd="\\" +tapefile=${TAPE-tar.out} + +Usage(){ + ex=$1 + shift +echo >&2 "Usage: `basename $0` [<options>] [<include/exclude files>] +Function: backup/restore a Windows PC directories to a local tape file +Options: (Description) (Default) + -r Restore from tape file to PC Save from PC to tapefile + -i Incremental mode Full backup mode + -v Verbose mode: echo command Don't echo anything + -s <server> Specify PC Server $server + -p <password> Specify PC Password $password + -x <share> Specify PC Share $service + -X Exclude mode Include + -N <newer> File for date comparison `set -- $newer; echo $2` + -b <blocksize> Specify tape's blocksize `set -- $blocksize; echo $2` + -d <dir> Specify a directory in share $cdcmd + -l <log> Specify a Samba Log Level `set -- $log; echo $2` + -u <user> Specify User Name $username + -t <tape> Specify Tape device $tapefile +" + echo >&2 "$@" + exit $ex +} -USAGE=$0" [ -pxut ] -s server\n - -p password\n - -x service\n - -n newer\n - -i incremental\n - -b blocksize\n - -r restore\n - -l log\n - -u user\n - -r restore\n - -t tape" - -while getopts ril:b:n:vs:p:x:u:t: c; do +while getopts rivl:b:d:N:s:p:x:u:Xt: c; do case $c in - r) tarcmd="tar x" - ;; - i) incremental="tarmode inc reset" + r) # [r]estore to Windows (instead of the default "Save from Windows") + tarcmd="x" ;; - l) log="-d $OPTARG" + i) # [i]ncremental + tarargs=${tarargs}g ;; - n) if [ -f $OPTARG ]; then - newer="newer $OPTARG" + l) # specify [l]og file + log="-d $OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, log level not numeric: -l $OPTARG" + exit 1 + esac + ;; + d) # specify [d]irectory to change to in server's share + cdcmd="$OPTARG" + ;; + N) # compare with a file, test if [n]ewer + if [ -f $OPTARG ]; then + newer=$OPTARG + tarargs=${tarargs}N else - echo $0: Warning, $OPTARG not found + echo >&2 $0: Warning, $OPTARG not found fi ;; - s) server=$OPTARG - ;; - b) blocksize="blocksize $OPTARG" + X) # Add exclude flag + tarargs=${tarargs}X ;; - p) password=$OPTARG + s) # specify [s]erver's share to connect to - this MUST be given. + server="$OPTARG" ;; - x) service=$OPTARG + b) # specify [b]locksize + blocksize="blocksize $OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, block size not numeric: -b $OPTARG" + exit 1 + esac + tarargs=${tarargs}b + ;; + p) # specify [p]assword to use + password="$OPTARG" + ;; + x) # specify windows [s]hare to use + service="$OPTARG" + ;; + t) # specify [t]apefile on local host + tapefile="$OPTARG" ;; - t) TF=$OPTARG + u) # specify [u]sername for connection + username="$OPTARG" ;; - u) username=$OPTARG + v) # be [v]erbose and display what's going on + verbose="" ;; - v) verbose="/dev/tty" - ;; - \?) echo $USAGE - exit 2 + '?') # any other switch + Usage 2 "Invalid switch specified - abort." ;; esac done - + shift `expr $OPTIND - 1` -if [ $service = "" ]; then - echo $USAGE - exit 1 +if [ "$server" = "" ] || [ "$service" = "" ]; then + Usage 1 "No server or no service specified - abort." fi -if [ -n $verbose ]; then - echo server is $server - echo service is $service - echo tar cmd is $tarcmd - echo password is $password - echo share is $service - echo tape is $TF +# if the -v switch is set, the echo the current parameters +if [ -z "$verbose" ]; then + echo "server is $server" +# echo "share is $service" + echo "share is $service\\$cdcmd" + echo "tar args is $tarargs" +# echo "password is $password" # passwords should never be sent to screen + echo "tape is $tapefile" + echo "blocksize is $blocksize" fi -( - echo "lowercase" - echo $newer - echo $blocksize - echo $incremental - echo $tarcmd $TF -) | $SMBCLIENT "\\\\$server\\$service" $password -U $username -N $log > $verbose +eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ +-E -N $log -D "'$cdcmd'" \ +-T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose + diff -u -r --new-file last-version/source/system.c samba-1.9.16alpha1/source/system.c --- last-version/source/system.c Mon Jan 15 13:12:05 1996 +++ samba-1.9.16alpha1/source/system.c Sun Feb 18 17:47:10 1996 @@ -21,6 +21,8 @@ #include "includes.h" +extern int DEBUGLEVEL; + /* The idea is that this file will eventually have wrappers around all important system calls in samba. The aim is twofold: @@ -45,13 +47,9 @@ #ifdef HAS_RDCHK r = rdchk(fd); -#endif - -#ifdef HAS_TCRDCHK +#elif defined(TCRDCHK) (void)ioctl(fd, TCRDCHK, &r); -#endif - -#ifdef HAS_FIONREAD +#else (void)ioctl(fd, FIONREAD, &r); #endif @@ -96,7 +94,7 @@ do { if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2)); errno = 0; - selrtn = select(FD_SETSIZE,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL); + selrtn = select(16,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL); } while (selrtn<0 && errno == EINTR); return(selrtn); diff -u -r --new-file last-version/source/trans2.c samba-1.9.16alpha1/source/trans2.c --- last-version/source/trans2.c Sun Dec 3 19:26:38 1995 +++ samba-1.9.16alpha1/source/trans2.c Thu Feb 29 00:12:08 1996 @@ -54,6 +54,7 @@ char *pp = params; char *pd = pdata; int params_sent_thistime, data_sent_thistime, total_sent_thistime; + int alignment_offset = 1; /* Initially set the wcnt area to be 10 - this is true for all trans2 replies */ @@ -68,13 +69,15 @@ } /* Space is bufsize minus Netbios over TCP header minus SMB header */ - useable_space = bufsize - (smb_buf(outbuf) - outbuf); - useable_space = MIN(useable_space, maxxmit); + /* The + 1 is to align the param and data bytes on an even byte + boundary. NT 4.0 Beta needs this to work correctly. */ + useable_space = bufsize - ((smb_buf(outbuf)+alignment_offset) - outbuf); + useable_space = MIN(useable_space, maxxmit); /* XXX is this needed? correct? */ while( params_to_send || data_to_send) { /* Calculate whether we will totally or partially fill this packet */ - total_sent_thistime = params_to_send + data_to_send; + total_sent_thistime = params_to_send + data_to_send + alignment_offset; total_sent_thistime = MIN(total_sent_thistime, useable_space); set_message(outbuf, 10, total_sent_thistime, True); @@ -100,7 +103,7 @@ parameter bytes, however the first 4 bytes of outbuf are the Netbios over TCP header. Thus use smb_base() to subtract them from the calculation */ - SSVAL(outbuf,smb_proff,(smb_buf(outbuf) - smb_base(outbuf))); + SSVAL(outbuf,smb_proff,((smb_buf(outbuf)+alignment_offset) - smb_base(outbuf))); /* Absolute displacement of param bytes sent in this packet */ SSVAL(outbuf,smb_prdisp,pp - params); } @@ -113,16 +116,17 @@ } else { /* The offset of the data bytes is the offset of the parameter bytes plus the number of parameters being sent this time */ - SSVAL(outbuf,smb_droff,(smb_buf(outbuf) - smb_base(outbuf)) + params_sent_thistime); + SSVAL(outbuf,smb_droff,((smb_buf(outbuf)+alignment_offset) - + smb_base(outbuf)) + params_sent_thistime); SSVAL(outbuf,smb_drdisp, pd - pdata); } /* Copy the param bytes into the packet */ if(params_sent_thistime) - memcpy(smb_buf(outbuf),pp,params_sent_thistime); + memcpy((smb_buf(outbuf)+alignment_offset),pp,params_sent_thistime); /* Copy in the data bytes */ if(data_sent_thistime) - memcpy(smb_buf(outbuf)+params_sent_thistime,pd,data_sent_thistime); + memcpy(smb_buf(outbuf)+alignment_offset+params_sent_thistime,pd,data_sent_thistime); DEBUG(9,("t2_rep: params_sent_thistime = %d, data_sent_thistime = %d, useable_space = %d\n", params_sent_thistime, data_sent_thistime, useable_space)); @@ -194,7 +198,7 @@ if (!check_name(fname,cnum)) return(UNIXERROR(ERRDOS,ERRnoaccess)); - unixmode = unix_mode(cnum,open_attr); + unixmode = unix_mode(cnum,open_attr | aARCH); open_file_shared(fnum,cnum,fname,open_mode,open_ofun,unixmode, @@ -258,7 +262,7 @@ char *p, *pdata = *ppdata; int reskey=0, prev_dirpos=0; int mode=0; - uint32 size=0; + uint32 size=0,len; uint32 mdate=0, adate=0, cdate=0; char *name_ptr; BOOL isrootdir = (strequal(Connections[cnum].dirpath,"./") || @@ -422,7 +426,9 @@ case SMB_FIND_FILE_BOTH_DIRECTORY_INFO: was_8_3 = is_8_3(fname); - SIVAL(p,0,94+strlen(fname)); p += 4; + len = 94+strlen(fname); + len = (len + 3) & ~3; + SIVAL(p,0,len); p += 4; SIVAL(p,0,reskey); p += 4; put_long_date(p,cdate); p += 8; put_long_date(p,adate); p += 8; @@ -439,7 +445,8 @@ #else strcpy(p+2,fname); #endif - name_map_mangle(p+2,True,SNUM(cnum)); + if (!name_map_mangle(p+2,True,SNUM(cnum))) + (p+2)[12] = 0; } else *(p+2) = 0; strupper(p+2); @@ -447,10 +454,13 @@ p += 2 + 24; /* name_ptr = p; */ strcpy(p,fname); p += strlen(p); + p = pdata + len; break; case SMB_FIND_FILE_DIRECTORY_INFO: - SIVAL(p,0,64+strlen(fname)); p += 4; + len = 64+strlen(fname); + len = (len + 3) & ~3; + SIVAL(p,0,len); p += 4; SIVAL(p,0,reskey); p += 4; put_long_date(p,cdate); p += 8; put_long_date(p,adate); p += 8; @@ -460,12 +470,15 @@ SIVAL(p,0,size); p += 8; SIVAL(p,0,mode); p += 4; SIVAL(p,0,strlen(fname)); p += 4; - strcpy(p,fname); p += strlen(p); + strcpy(p,fname); + p = pdata + len; break; case SMB_FIND_FILE_FULL_DIRECTORY_INFO: - SIVAL(p,0,68+strlen(fname)); p += 4; + len = 68+strlen(fname); + len = (len + 3) & ~3; + SIVAL(p,0,len); p += 4; SIVAL(p,0,reskey); p += 4; put_long_date(p,cdate); p += 8; put_long_date(p,adate); p += 8; @@ -476,14 +489,18 @@ SIVAL(p,0,mode); p += 4; SIVAL(p,0,strlen(fname)); p += 4; SIVAL(p,0,0); p += 4; - strcpy(p,fname); p += strlen(p); + strcpy(p,fname); + p = pdata + len; break; case SMB_FIND_FILE_NAMES_INFO: - SIVAL(p,0,12+strlen(fname)); p += 4; + len = 12+strlen(fname); + len = (len + 3) & ~3; + SIVAL(p,0,len); p += 4; SIVAL(p,0,reskey); p += 4; SIVAL(p,0,strlen(fname)); p += 4; - strcpy(p,fname); p += strlen(p); + strcpy(p,fname); + p = pdata + len; break; default: @@ -1293,7 +1310,7 @@ if(sys_utime(fname, &tvs)!=0) return(ERROR(ERRDOS,ERRnoaccess)); } - if(mode != dos_mode(cnum,fname,&st) && dos_chmod(cnum,fname,mode)) { + if(mode != dos_mode(cnum,fname,&st) && dos_chmod(cnum,fname,mode,NULL)) { DEBUG(2,("chmod of %s failed (%s)\n", fname, strerror(errno))); return(ERROR(ERRDOS,ERRnoaccess)); } @@ -1541,7 +1558,7 @@ receive_smb(Client,inbuf, 0); /* Ensure this is still a trans2 packet (sanity check) */ - if(CVAL(inbuf, smb_com) != SMBtrans2) + if(CVAL(inbuf, smb_com) != SMBtranss2) { outsize = set_message(outbuf,0,0,True); DEBUG(2,("Invalid secondary trans2 packet\n")); diff -u -r --new-file last-version/source/util.c samba-1.9.16alpha1/source/util.c --- last-version/source/util.c Tue Jan 16 10:14:44 1996 +++ samba-1.9.16alpha1/source/util.c Thu Feb 29 00:12:08 1996 @@ -536,6 +536,8 @@ } +static char *last_ptr=NULL; + /**************************************************************************** Get the next token from a string, return False if none found handles double-quotes. @@ -544,7 +546,6 @@ ****************************************************************************/ BOOL next_token(char **ptr,char *buff,char *sep) { - static char *last_ptr=NULL; char *s; BOOL quoted; @@ -578,6 +579,44 @@ return(True); } +/**************************************************************************** +Convert list of tokens to array; dependent on above routine. +Uses last_ptr from above - bit of a hack. +****************************************************************************/ +char **toktocliplist(int *ctok, char *sep) +{ + char *s=last_ptr; + int ictok=0; + char **ret, **iret; + + if (!sep) sep = " \t\n\r"; + + while(*s && strchr(sep,*s)) s++; + + /* nothing left? */ + if (!*s) return(NULL); + + do { + ictok++; + while(*s && (!strchr(sep,*s))) s++; + while(*s && strchr(sep,*s)) *s++=0; + } while(*s); + + *ctok=ictok; + s=last_ptr; + + if (!(ret=iret=malloc(ictok*sizeof(char *)))) return NULL; + + while(ictok--) { + *iret++=s; + while(*s++); + while(!*s) s++; + } + + return ret; +} + +#ifndef HAVE_MEMMOVE /******************************************************************* safely copies memory, ensuring no overlap problems. this is only used if the machine does not have it's own memmove(). @@ -635,6 +674,7 @@ } return(dest); } +#endif /**************************************************************************** @@ -1196,6 +1236,7 @@ ********************************************************************/ BOOL strequal(char *s1,char *s2) { + if (s1 == s2) return(True); if (!s1 || !s2) return(False); return(StrCaseCmp(s1,s2)==0); @@ -1206,6 +1247,7 @@ ******************************************************************/ BOOL strnequal(char *s1,char *s2,int n) { + if (s1 == s2) return(True); if (!s1 || !s2 || !n) return(False); return(StrnCaseCmp(s1,s2,n)==0); @@ -1216,6 +1258,7 @@ ********************************************************************/ BOOL strcsequal(char *s1,char *s2) { + if (s1 == s2) return(True); if (!s1 || !s2) return(False); return(strcmp(s1,s2)==0); @@ -1904,6 +1947,9 @@ if ((*mext == 0) && doext && !hasdot) strcpy(mext,"???"); + if (strequal(mbeg,"*") && *mext==0) + strcpy(mext,"*"); + /* expand *'s */ expand_one(mbeg,8); if (*mext) @@ -2149,6 +2195,7 @@ int readret; int nread = 0; struct timeval timeout, tval1, tval2, tvaldiff; + int error_limit = 5; /* just checking .... */ if (maxcnt <= 0) return(0); @@ -2201,61 +2248,60 @@ nread = 0; /* Number of bytes we have read */ for(;;) - { - + { FD_ZERO(&fds); FD_SET(fd,&fds); selrtn = sys_select(&fds,&timeout); /* Check if error */ - if(selrtn == -1) - { - errno = EBADF; - return -1; - } + if(selrtn == -1) { + errno = EBADF; + return -1; + } /* Did we timeout ? */ - if (selrtn == 0 ) { - if (nread < mincnt) return -1; + if (selrtn == 0) { + if (nread < mincnt) return -1; break; /* Yes */ } - readret = read( fd, buf+nread, maxcnt-nread); - if(readret <= 0) - { - /* force a particular error number for - portability */ - errno = EBADF; - return -1; - } + readret = read(fd, buf+nread, maxcnt-nread); + if (readret == 0 && nread < mincnt) { + /* error_limit should not really be needed, but some systems + do strange things ... I don't want to just continue + indefinately in case we get an infinite loop */ + if (error_limit--) continue; + return(-1); + } - if (readret == 0) - break; + if (readret < 0) { + /* force a particular error number for + portability */ + DEBUG(5,("read gave error %s\n",strerror(errno))); + errno = EBADF; + return -1; + } nread += readret; /* If we have read more than mincnt then return */ - if( nread >= mincnt ) + if (nread >= mincnt) break; /* We need to do another select - but first reduce the time_out by the amount of time already elapsed - if this is less than zero then return */ - if (exact) - { - GetTimeOfDay( &tval2); - (void)tval_sub( &tvaldiff, &tval2, &tval1); + if (exact) { + GetTimeOfDay(&tval2); + (void)tval_sub( &tvaldiff, &tval2, &tval1); - if( tval_sub( &timeout, &timeout, &tvaldiff) <= 0) - { - /* We timed out */ - break; - } - } + if (tval_sub(&timeout, &timeout, &tvaldiff) <= 0) + break; /* We timed out */ + } /* Save the time of day as we need to do the select - again (saves a system call)*/ + again (saves a system call) */ tval1 = tval2; } @@ -3948,21 +3994,32 @@ sprintf(pidstr,"%d",(int)getpid()); string_sub(s,"%d",pidstr); } + + if (!strchr(s,'%')) return; + + { + struct passwd *pass = Get_Pwnam(sesssetup_user,False); + if (pass) { + string_sub(s,"%G",gidtoname(pass->pw_gid)); + } + } } /******************************************************************* write a string in unicoode format ********************************************************************/ -void PutUniCode(char *dst,char *src) +int PutUniCode(char *dst,char *src) { + int ret = 0; while (*src) { - dst[0] = src[0]; - dst[1] = 0; - dst += 2; + dst[ret++] = src[0]; + dst[ret++] = 0; src++; } - dst[0] = dst[1] = 0; + dst[ret++]=0; + dst[ret++]=0; + return(ret); } @@ -4084,7 +4141,7 @@ ********************************************************************/ char *uidtoname(int uid) { - static char name[20]; + static char name[40]; struct passwd *pass = getpwuid(uid); if (pass) return(pass->pw_name); sprintf(name,"%d",uid); @@ -4096,7 +4153,7 @@ ********************************************************************/ char *gidtoname(int gid) { - static char name[20]; + static char name[40]; struct group *grp = getgrgid(gid); if (grp) return(grp->gr_name); sprintf(name,"%d",gid); diff -u -r --new-file last-version/source/version.h samba-1.9.16alpha1/source/version.h --- last-version/source/version.h Tue Jan 16 20:37:41 1996 +++ samba-1.9.16alpha1/source/version.h Thu Feb 29 00:23:15 1996 @@ -1 +1 @@ -#define VERSION "1.9.15p8" +#define VERSION "1.9.16alpha1"